write c++ program to read two inputs and find the maximum by using switch statement only
- برمجة سي بلس بلس
- 2021-12-03
- softwareEngineer
الأجوبة
#include <iostream>
using namespace std;
int main()
{
int num1, num2;
/* Input two numbers from user */
cout<<"Enter first number";
cin>>num1;
cout<<"Enter second number";
cin>>num2;
/* Expression (num1 > num2) will return either 0 or 1 */
switch(num1 > num2)
{
/* If condition (num1>num2) is false */
case 0:
cout<<num2<<" is maximum";
break;
/* If condition (num1>num2) is true */
case 1:
cout<<num1<<" is maximum";
break;
}
return 0;
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال