c program to find largest of 3 numbers using if else
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
printf("\n Enter the three digits");
scanf("%d%d%d", &a, &b,&c);
if((a>b)&&(b>c))
{
printf("largest number=%d",a);
}
else if(b>c)
{
printf("largest number=%d",b);
}
else
{
printf("\n largest number=%d",c);
}
getch();
}
output
The first user has to give three digits which is store in a, b, c respectively.
Then,
IF if((a>b)&&(b>c)) condition is true and printf("largest number=%d",a); display the a is largest number.
If first condition is false then program goes
In this condition, If it is true else if(b>c) then printf("largest number=%d",b); display the b is largest numbe.
If secondition also become false then
printf("\n largest number=%d",c); display the c is largest number.




0 Comments
Please do not enter any spam link on comment box