Monday, August 30, 2010

C Program to get the largest of three numbers

#include<stdio.h>
#include<conio.h>
void main()
{
     int a,b,c;
     clrscr();
     printf("\n\n Enter the values of three numbers \n\n");
     scanf("%d%d%d",&a,&b,&c);
     printf("\n The values of three numbers are \n");
     printf(" a = %d\n",a);
     printf(" b = %d\n",b);
     printf(" c = %d\n",c);
     if(a>b)
     {
        if(a>c)
          printf("\ta = %d is larger ",a);
        else
          printf("\tc = %d is larger ",c);
     }
     else
     {
         if(c>b)
            printf("\tc = %d is larger",c);
         else
            printf("\tb = %d is larger",b);
     }
     getch();
}

No comments:

Post a Comment