Header Ads Widget

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

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

Given three numbers , write a program to find the largest among three numbers . 

Sample input

2 5 8

Sample output

8 is largest number

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

The objective of the code is to find the largest among three numbers .

Code(C):-

#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 number",c);
}
else
{
if(b>c)
printf("%d is the largest number ",b);
else
printf("%d is the largest number ",c);
}
return 0;
}

Output:-

Enter three numbers
2 5 8
8 is the largest number


Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-