C Program to find smallest of three numbers using nested If Else statement
Program
#include<stdio.h>
void main()
{
int a, b, c;
printf("Enter three numbers:\n");
scanf("%d %d %d", &a, &b, &c);
if(a < c)
{
if(a < b)
{
printf("a: %d is smallest\n", a);
}
else
{
printf("b: %d is smallest\n", b);
}
}
else if(b < c)
printf("b: %d is smallest\n", b);
else
printf("c: %d is smallest\n", c);
}
Output 1
Enter three numbers:
10
21
36
a: 10 is smallest
Output 2
Enter three numbers:
23
9
45
b: 9 is smallest
Output 3
Enter three numbers:
96
52
8
c: 8 is smallest