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

  1. C Program to Find the Largest Number Among Three Numbers
  2. C++ program to find greatest number between three numbers
  3. C and C++ Greater number using if else if
Share.

I'm a full-stack developer, specializing in the PHP, JS, Wordpress, MEAN Stack, MERN Stack & Django. I hold a high standard of quality in everything that I do.

Leave A Reply