Greatest of the Three Numbers in C++

Write a Program to Find the Greatest of the Three Numbers.

Write a Program to Find the Greatest of the Three Numbers.

Greatest of the Three Numbers

Program:


// C++ program to find greatest

// among three numbers using

#include <iostream>

using namespace std;

int main()

{

    int a = 10, b = 20, c = 30;

    cout << "The Greatest Among Three Numbers is : ";

    if (a >= b && a >= c) {

        cout << a << endl;

    }

    else if (b >= a && b >= c) {

        cout << b << endl;

    }

    else {

        cout << c << endl;

    }

    return 0;

}


Output:

The Greatest Among Three Numbers is : 30

Post a Comment