How to calculate greatest of four no. using nested if?
CODE
How to calculate
greatest of four no. using nested if
int main()
{
int a,b,c,d;
printf("\n enter the value of a,b,c,d:");
scanf("%i%d%d%d",&a,&b,&c,&d);
if(a>b)
{
if(a>c)
{
if(a>d)
printf("\n a is greatest");
else
printf("\n d is greatest");
}
else
if(c>d)
printf("\n c is greatest");
else
printf("\n d is greatest");
}
else
if(b>c)
{
if(b>d)
printf("\n b is greatest");
else
printf("\n d is greatest");
}
else
if(c>d)
printf("\n c is greatest");
else
printf("\n d is greatest");
}
Output:
enter the value of a,b,c,d:
2
5
6
3
c is greatest
How to calculate greatest of four no. using nested if?
Reviewed by Unknown
on
December 15, 2018
Rating:
No comments:
If you have any doubt or query ,comment below: