C++ Program to Find Greatest Among Three Numbers Using if-else (तीन संख्याओं में सबसे बड़ी संख्या ज्ञात करना)

In this program, we use nested if-else statements to find the greatest or largest among three numbers.

इस प्रोग्राम में nested if-else statements की सहायता से तीन संख्याओं में से सबसे बड़ी संख्या ज्ञात की जाती है।

Program:

#include <iostream>
using namespace std;

int main()
{
    float a, b, c;

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

    if (a > b)
    {
        if (a > c)
        {
            cout << a << " is greatest" << endl;
        }
        else
        {
            cout << c << " is greatest" << endl;
        }
    }
    else
    {
        if (b > c)
        {
            cout << b << " is greatest" << endl;
        }
        else
        {
            cout << c << " is greatest" << endl;
        }
    }

    return 0;
}

Output 1:

Enter Three Numbers: 10 25 15
25 is greatest

Output 2:

Enter Three Numbers: 50 20 80
80 is greatest

Output 3:

Enter Three Numbers: 100 50 25
100 is greatest

Explanation (व्याख्या)

  1. First, the program compares a and b.

  2. If a > b, then a is compared with c.

  3. Otherwise, b is compared with c.

  4. The greatest number is displayed.

  5. सबसे पहले प्रोग्राम a और b की तुलना करता है।

  6. यदि a > b है, तो a की तुलना c से की जाती है।

  7. अन्यथा b की तुलना c से की जाती है।

  8. सबसे बड़ी संख्या को प्रदर्शित किया जाता है।

This program demonstrates the use of nested if-else statements to compare three numbers and display the greatest value.

यह प्रोग्राम तीन संख्याओं की तुलना करके सबसे बड़ी संख्या प्रदर्शित करने के लिए nested if-else statements का प्रयोग दर्शाता है।

Comments

Popular posts from this blog

Important Questions (IMP) of Programming Methodologies and Data structures using C++ with OOP's Concepts

Programming Methodologies and Data structures using C++ Language with OOP's Concepts

OOP's using CPP Syllabus AND Programming Methodologies and Data Structures Using C++ (NEP 2020)