I/O Operations SRM Calculator
SRM Students decides to create a software to extend our help to Petty shops and Shops. In this regard the "STUDENT" team has selected a few students to complete the task. The task was monitored by a group of experts and the software was tested by a expert team from corporate.
The task is as follows when there are two items and if the shop keeper says 1 then it needs to add the two items. If the shop keeper yells 2 then the two items should be subtracted. And when the shop keeper tells 3 then the product of the items needs to be outputted. When shop keeper tells as 4 then the items should fight with one another.
Refer sample input and output:
Input should be between 1 to 4
Only Integer numbers as input.
If input is less than or greater than 1 to 4 print "Invalid Input".
The task is as follows when there are two items and if the shop keeper says 1 then it needs to add the two items. If the shop keeper yells 2 then the two items should be subtracted. And when the shop keeper tells 3 then the product of the items needs to be outputted. When shop keeper tells as 4 then the items should fight with one another.
Refer sample input and output:
Input should be between 1 to 4
Only Integer numbers as input.
If input is less than or greater than 1 to 4 print "Invalid Input".
TEST CASE 2
INPUT
INPUT
2
35 36
OUTPUT-1
#include <iostream>
using namespace std;
int main() {
int option,num1,num2;
cin>>option;
if(option<5 && option>0){
cin>>num1>>num2;
if(option==1)
cout<<num1+num2;
else if(option==2)
cout<<num1-num2;
else if(option==3)
cout<<num1*num2;
else
cout<<num1/num2;
}
else{
cout<<"Invalid Input";
}
return 0;
}
Comments
Post a Comment