C Program to Find Largest from Three Numbers


Program


#include<stdio.h>
#include<conio.h>

int main()
{
	 float a,b,c,lg;
	 clrscr();
	 printf("Enter three numbers:\n");
	 scanf("%f%f%f",&a,&b,&c);
	 lg = a;
	 
	 if(b>lg)
	 {
	  lg = b;
	 }
	 
	 if(c>lg)
	 {
	  lg = c;
	 }
	 
	 printf("Largest = %0.2f", lg);
	 getch();
	 
	 return(0);
}

Output of the above program :

Run 1:
------------
Enter thre numbers:
56 ↲
78 ↲
67 ↲
Largest = 78.00

Run 2:
------------
Enter thre numbers:
-89 ↲
-78 ↲
-67 ↲
Largest = -67.00

Note: ↲ indicates ENTER is pressed.