Find the largest of three numbers given using c program




To do the C program to find biggest of three numbers we need to get the input three numbers from user. Here we are using if - else condition to check the biggest.

In the first if statement we check a is greater than b if that condition matches a is checked with c. If that condition also gets matched print a as biggest, else print c as biggest.

else check if b greater than c if that condition is true print b as biggest of three. else print c as biggest.

===================================================================
#include <stdio.h>
 
#include <conio.h>
 
#include <math.h>
 
void main()
 
{
 
	int  a, b, c;
 
	clrscr();
 
	printf("Enter the values of a,b and c\n");
 
   	scanf ("%d %d %d", &a, &b, &c);
 
   	printf ("a = %d\tb = %d\tc = %d\n", a,b,c);
 
  	 if ( a > b)
 
	 {
 
		if ( a > c)
 
		{
 
	   		 printf ("A is the greatest among three\n");
 
		}
 
		else
 
		{
 
		 	printf ("C is the greatest among three\n");
 
		}
 
	 }
 
	 else if (b > c)
 
	 {
 
		printf ("B is the greatest among three\n");
 
	 }
 
	 else
 
		printf ("C is the greatest among three\n");
 
}
 
==================================================================
OUTPUT of C program to find the largest of three numbers
==================================================================
Output
Enter the values of a,b and c
23 32 45
a = 23 b = 32 c = 45
C is the greatest among three

RUN2
Enter the values of a,b and c
234
678
195
a = 234 b = 678 c = 195
B is the greatest among three

RUN3
Enter the values of a,b and c
30 20 10
a = 30 b = 20 c = 10
A is the greatest among three