In: Computer Science
Write a program that allows the user to enter two integers and a character If the character is A, add the two integers If it is S, subtract the second integer from the first else multiply the integers Display the results of the arithmetic
Since you have not specified the programming language to be used in the question, so I am provided you the code in C++ programming language. In case you want the solution in any other language, then let me know in the comment.
CODE :
#include <iostream>
using namespace std;
int main()
{
int a,b;
char ch;
cout<<"Enter the two integers : ";
cin>>a>>b;
cout<<"Enter the character : ";
cin>>ch;
switch(ch){
case 'A': cout<<"The sum of the integers is :
"<<a+b;
break;
case 'S': cout<<"The difference of the integers is :
"<<a-b;
break;
default: cout<<"The product of the integers is :
"<<a*b;
break;
}
return 0;
}
SAMPLE OUTPUT1 :
SAMPLE OUTPUT2 :
SAMPLE OUTPUT3 :
If you have any doubt/query regarding the above solution, then let me know in the comment. If the solution helps, do give an upVote to this answer.