Answer:
#include <iostream>
using namespace std;
int main()
{
char opt;
double num1,num2;
cout<<"Enter an operation(+,-,*,/), Q to quit: ";
cin>>opt;
while(opt != 'Q'){
cout<<"\\Enter your first number: ";
cin>>num1;
cout<<"\\Enter your second number: ";
cin>>num2;
if(opt == '+'){
cout<<"Result = "<<num1+num2<<endl;
}else if(opt == '-'){
cout<<"Result = "<<num1-num2<<endl;
}else if(opt == '*'){
cout<<"Result = "<<num1*num2<<endl;
}else if(opt == '/'){
cout<<"Result = "<<num1/num2<<endl;
}
cout<<"Enter an operation(+,-,*,/), Q to quit: ";
cin>>opt;
}
return 0;
}
Step-by-step explanation:
First, include the library iostream, it allows to use the input/output instruction.
Create the main function and declare the variables.
Then print the message on the screen using cout instruction.
cin instruction is used to store the value into the variable.
then, take a while and check the condition if the value enters by the user is 'Q' or not. if true then enter the while otherwise exit.
after that, store the number enter by the user in the variables and then take the if-else statement for matching the operation enter by the user if match true then do the match operation.
This process continues until the user enters the value 'Q'.
if the user enters the 'Q' then condition false and exit the program.