C Books Guide and List
C++ Books Guide and List
Best Java Books

C program to find the greatest of three numbers.

+2 votes
2,000 views asked Jul 13, 2011 by Smita Advisor (7,140 points)

2 Answers

+1 vote
Program:
#include <stdio.h>
int main()
{
 int a, b, c;
 printf("Enter a,b,c: \n");
 scanf("%d %d %d", &a, &b, &c);

 if (a > b && a > c)
{
 printf("a is Greater than b and c");
 }
 else if (b > a && b > c)
{
 printf("b is Greater than a and c");
 }
 else if (c > a && c > b)
{
 printf("c is Greater than a and b");
 }
 else
{
 printf("all are equal or any two values are equal");
 }
 return 0;
}


Output:
Enter a,b,c: 3 5 8
c is Greater than a and b
answered Jul 19, 2011 by sagar Expert (12,340 points)
0 votes

 

#include<stdio.h>
main()
{
int a,b,c;
printf("\n Input the three numbers :");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("\n Maximum= %d\n",a);
}
else
{
printf("Maximum= %d\n",c);
}
}
else if(b>c)
printf("\n Maximum= %d\n",b);
else
printf("\n Maximum= %d\n",c);
}
answered Sep 13, 2011 by Alokesh Ghosh Sr Member (1,180 points)

Related questions

0 votes
2 answers 13 views
+1 vote
2 answers 1,360 views
1,360 views asked Aug 17, 2011 by anonymous
+1 vote
2 answers 2,529 views
2,529 views asked Sep 12, 2011 by Prahasan Prasad Jr Member (390 points)
0 votes
1 answer 41 views
+2 votes
2 answers 2,962 views
2,962 views asked Jul 13, 2011 by Smita Advisor (7,140 points)
...