C Program to Find Smallest from Three Numbers

Program


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

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

Output

Run 1:
------------
Enter thre numbers:
56 ↲
78 ↲
67 ↲
Smallest = 56.00

Run 2:
------------
Enter thre numbers:
-89 ↲
-78 ↲
-67 ↲
Smallest = -89.00

Note: ↲ indicates ENTER is pressed.