ProAnswers.org

C program to find the greatest of three numbers.

2 Likes

Program:
#include
int main()
{
int a, b, c;
printf(“Enter a,b,c:
“);
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

#include

main()

{

int a,b,c;

printf("

Input the three numbers :");

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

if(a>b)

{

if(a>c)

{

printf("

Maximum= %d
",a);

}

else

{

printf("Maximum= %d

",c);

}

}

else if(b>c)

printf("

Maximum= %d
",b);

else

printf("

Maximum= %d
",c);

}