81: Program to find the maximum between three numbers. Using the switch statement.
// Program to find the maximum between three numbers. Using the switch statement.
// ****************************************************************************************************************************
#include <iostream>
using namespace std;
int main()
{
float num1, num2, num3;
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
cout << "Enter third number: ";
cin >> num3;
switch (num1 > num2)
{
case 1:
switch (num1 > num3)
{
case 1:
cout << num1 << " is the greatest";
break;
case 0:
cout << num3 << " is the greatest";
break;
}
break;
case 0:
switch (num2 > num3)
{
case 1:
cout << num2 << " is the greatest";
break;
case 0:
cout << num3 << " is the greatest";
break;
}
break;
default:
cout << "Invalid Input";
break;
}
return 0;
}
Comments
Post a Comment