Program to find maximum of three numbers

Program to find maximum of three numbers


Program:

#include<stdio.h>
void main()
{
int a,b,c;
printf("enter three numbers to be compared: ");
scanf("%d%d%d",&a,&b,&c);
if(a==b && b==c)
{
printf("%d is same everywhere so it is greatest",a);
}
else if(a==b&& a>c)
{
printf("%d is greatest",a);
}
else if(a==c&& a>b)
{
printf("%d is greatest",a);
}
else if(a>b&& a>c)
{
printf("%d is greatest",a);
}
else if(b>a&& b>c)
{
printf("%d is greatest",b);
}
else
{
printf(""%d is greatest",c);
}
}

Output:












Note: We have used and(&&) operator in this program. And condition becomes true if and only if both statements are true.

No comments:

Post a Comment