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 greatestOutput 2:
Enter Three Numbers: 50 20 80
80 is greatestOutput 3:
Enter Three Numbers: 100 50 25
100 is greatestExplanation (व्याख्या)
First, the program compares
aandb.If
a > b, thenais compared withc.Otherwise,
bis compared withc.The greatest number is displayed.
सबसे पहले प्रोग्राम
aऔरbकी तुलना करता है।यदि
a > bहै, तोaकी तुलनाcसे की जाती है।अन्यथा
bकी तुलनाcसे की जाती है।सबसे बड़ी संख्या को प्रदर्शित किया जाता है।
This program demonstrates the use of nested if-else statements to compare three numbers and display the greatest value.
यह प्रोग्राम तीन संख्याओं की तुलना करके सबसे बड़ी संख्या प्रदर्शित करने के लिए nested if-else statements का प्रयोग दर्शाता है।
Comments
Post a Comment