C Program to find biggest of three numbers using else if ladder:
#include <stdio.h>
#include<conio.h>
int main() {
double a, b, c;
printf("Enter any three numbers: ");
scanf("%lf %lf %lf", &a, &b, &c);
// if a is bigger than both b and c, a is the largest
if (a >= b && a >= c)
printf("%lf is the biggest number.", a);
// if b is bigger than both a and c, b is the largest
else if (b >= a && b >= c)
printf("%lf is the largest number.", b);
// if both above conditions are false, c is the largest
else
printf("%lf is the biggest number.", c);
getch();
return 0;
}
Output:
Enter any three numbers: 5 1.23 0.65
5.000000 is the biggest number.
Additional information:
if else statement:
It is a decision making statement.
It is a two way branching statement.
If the condition evaluates to true, statements which are inside the if block are executed.
If the condition evaluates to false, statements which are inside the else block are executed.
Syntax:
if(condition){
//statements to be executed if condition is true
}else{
//statements to be executed if condition is false
}
Example 1:
if( age >= 18 )
printf(“student can vote in the election”);
else
pintf(“student can not vote in the election”);
Example 2:
if ( percentage >= 35 )
printf(“The student result is: Pass”);
else
printf(“The student result is: Fail”);