This program shows the greatest number between three numbers using if-else-if statement. It takes three numbers as input from user and output the greatest number.
C Code
#include <stdio.h>
int main()
{
float a, b, c;
printf("Enter three numbers: ");
scanf("%f %f %f", &a, &b, &c);
if(a>=b && a>=c)
printf("Largest number = %.2f", a);
else if(b>=a && b>=c)
printf("Largest number = %.2f", b);
else
printf("Largest number = %.2f", c);
return 0;
}
C++ Code
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cout << " Enter Value for First Number: ";
cin >> a;
cout << "Enter Value for Second Number: ";
cin >> b;
cout << "Enter Value for Third Number: ";
cin >> c;
if(a>=b && a>=c)
{
cout << a << " is Greater.";
}
else if(b>=a && b>=c)
{
cout << b << " is Greater.";
}
else
{
cout << c << " is Greater.";
}
return 0;
}
Output:
Other Related Search Terms
- C Program to Find the Largest Number Among Three Numbers
- C++ program to find greatest number between three numbers
- C and C++ Greater number using if else if

![[C/C++] Program to Find Greatest Among Three Numbers](https://fsconline.info/wp-content/uploads/2015/09/c-cpp-programming.jpg)
