Saturday, 13 December 2014

C PROGRAM FOR LARGEST OF THREE NUMBERS


Write a program to find the largest of three numbers

#include<stdio.h>
#include<conio.h>
int main()
{
int a, b, c;
clrscr();
     printf("Enter the three numbers");
scanf("%d %d %d",&a, &b, &c);
if(a>b)
{
  if(a>c)
      printf("The largest number is: %d",a);
   else
      printf("The largest number is: %d",c);
}
else
{
     if(b>c)
      printf("The largest number is: %d",b);
     else
      printf("The largest number is: %d",c);
}
getch();
return(0);
}

OUTPUT:
Enter the three numbers
1 2 3
The largest number is 3

No comments:

Post a Comment