Program: 12
Write a C program to find the greatest number among three numbers.
#include
#include
void main()
{
int a, b, c;
printf("Enter A: ");
scanf("%d", &a);
printf("Enter B: ");
scanf("%d", &b);
printf("Enter C: ");
scanf("%d", &c);
if(a>b)
{
if(a>c)
{
printf("The value of A = %d is greatest.", a);
}
else
printf("The value of C = %d is greatest.", c);
}
else
{
if(b>c)
{
printf("The value of B = %d is greatest.", b);
}
else
printf("The value of C = %d is greatest.", c);
}
getch();
}
|
Output |
Enter A: 34 Enter B: 3 Enter C: 76 The value of C = 76 is greatest
|
Leave a Comment