Monday, June 18, 2012

To find the greatest among three numbers


/* To find the greatest among three numbers */

#include<stdio.h>

#include<conio.h>

void main()

{

 int a,b,c;

 clrscr();

 printf("Enter any three numbers: \n");

 scanf("%d%d%d",&a,&b,&c);

 if(a>b)

 {

   if(a>c)

     printf("\nFirst number is the largest");

   else

     printf("\nThird number is the largest");

 }

 else

 {

   if(b>c)

     printf("\nSecond number is the largest");

   else

     printf("\nThird number is the largest");

 }

 getch();

}

 

OUTPUT

Enter any three numbers:

23

59

47

 

Second number is the largest

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.