Learn about Finding Largest in Three Numbers in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Finding Largest in Three Numbers in C
The below C program finds the biggest of the three numbers from the user input. Several if-else statements are used to check all the possible conditions before printing the correct result.
Source code:
#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter three number: ");
scanf("%d %d %d", &a, &b, &c);
if(a==b && a==c) printf("All are equal.");
else if(a>b && a>c) printf("a is big.");
else if(a==b && a>c) printf("a & b are big.");
else if(b==c && b>a) printf("b & c are big.");
else if(a==c && a>b) printf("a & c are big.");
else if(b>c) printf("b is big.");
else printf("c is big.");
return 0;
}
Output:
Enter three number: 1 2 3
c is big.
Enter three number: 5 2 5
a & c are big.
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
Finding Largest in Two Number in C
C Program to Find Even or Odd using if-else