Write a program to find the largest of three numbers using nested if else

 Code:-

#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c;
printf(“Enter three numbers n”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
{
if(a>c)
printf(“%d is the largest number”,a);
else
printf(“%d is the largest”,c);
}
else
{
if(b>c)
printf(“%d is the largest number”,b);
else
printf(“%d is the largest”,c);
}
return 0;
}

Output:-

Enter three numbers
2 4 5
5 is the largest



Leave a Reply

Your email address will not be published.