C++ Program to find greatest number among three numbers


In this Example, You will learn how to find greatest number among three numbers in C++.


List is :10 20 40 => 40

List is :30 20 10 => 30


Example: How to find greatest number among three numbers in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int a, b, c;

    cout << "Enter Three Numbers :";
    cin >> a >> b>>c;

    if (a > b && a > c) {
        cout << "\na is greatest :" << a;
    } else if (b > c) {
        cout << "\nb is greatest :" << b;
    } else {
        cout << "\nc is greatest :" << c;
    }

    return 0;
}

Output:

Enter Three Numbers :12 131 14
b is greatest :131