Selecting the largets of three numbers

Program 16) This program selects and prints the largest of the three numbers using nested if....else statements.

                                   PROGRAM

main ( )
 {
       float A, B, C ;
       
       printf ("Enter three values\n") ;
       scanf ("%f %f %f, &A, &B, &C) ;

       printf ("\nlargest value is ") ;
       if (A>B)
        {
            if (A>C)
                printf ("%f\n", A) ;
            else
                printf ("%f\n", C) ;
        }
        else

         {
             if (C>B)
                 printf ("%f\n", C) ;
             else
                 printf ("%f\n", B) ;
        }
      getch( ) ;
 }

Output:          Enter three values
                      23445 67379 88843

                     Largest value is 88843.oooooo 

No comments:

Post a Comment