C Program to find the biggest of three numbers using Nested if-else statement.
This program finds the largest of 3 numbers using nested if else statement. Nested if else statement is the easiest way to find the biggest number.
if else statement is a decision making statement.
Description:
Program takes any 3 numbers and prints the greatest number using the nested if else.
a, b and c are three input integer or float or double numbers.
The task is to compare all the 3 input variables and print the largest number.
Algorithm to calculate biggest of 3 numbers:
STEP 1: START
STEP 2: READ any three numbers
READ a, b, c
STEP 3: COMPARE a with b and c
Compare a and b
if a >= b
if a is greater than b compare a with c
if a >= c
PRINT “a is Biggest”
Otherwise
PRINT “c is Biggest”
STEP 4: OTHERWISE COMPARE b with c
if b >= c
PRINT “b is Biggest”
Otherwise
PRINT “c is Biggest”
STEP 5: END
Program to find biggest of three numbers:
#include <stdio.h>
#include<conio.h>
int main() {
double a, b, c;
printf("Enter any 3 integer or float numbers: ");
scanf("%lf %lf %lf", &a, &b, &c);
if (a >= b) {
if (a >= c)
printf("%lf is the biggest number.", a);
else
printf("%lf is the biggest number.", c);
}
else {
if (b >= c)
printf("%lf is the biggest number.", b);
else
printf("%lf is the biggest number.", c);
}
getch();
return 0;
}
output 1:
Enter any 3 integer or float numbers: -4 2 8
8.000000 is the biggest number.
output 2:
Enter any 3 integer or float numbers: 2.23 -6.1 0.91
2.230000 is the biggest number.