#include <iostream>
using namespace std;
main()
{
int number1,number2;
char op;
int answer, answer1, answer2, answer3;
cout << "Enter value of number1: ";
cin >> number1;
cout << "Chose your Operator:";
cout<<"Press1 for +, press2 for -, press3 for *, press4 for/"<<endl;
cin >> op;
cout << "Enter value of number2: ";
cin >> number2;
if (op == '1')
{answer = number1 + number2;
cout << "Answer: " << answer << endl;}
else if (op == '2')
{answer1 = number1 - number2;
cout << "Answer: " << answer1 << endl;}
else if(op == '3')
{answer2 = number1 * number2;
cout << "Answer: " << answer2 << endl;}
else if (op == '4')
{answer3 = number1 / number2;
cout << "Answer: " << answer3 << endl;}
return 0;
}
Output:
No comments:
Post a Comment