how to build a calculator using c 2b 2b

Solutions on MaxInterview for how to build a calculator using c 2b 2b by the best coders in the world

showing results for - "how to build a calculator using c 2b 2b"
Fabio
23 Jun 2020
1#include <iostream>
2
3using namespace std;
4
5int main()
6{
7int num1;
8int num2;
9char op;
10  
11  cout << "Enter a number:" << endl;
12  cin >> num1; //takes input
13  
14  cout << "Enter another number:" << endl; //prints some prompt
15  cin >> num2;
16  
17  cout << "Enter a operator:" << endl; //prints some prompt
18  cin >> op;
19  
20  if(op == '+')
21  {
22  cout << "Result = " << num1 + num2 << endl;
23  }else if(op == '-'){
24  cout << "Result = " << num1 - num2 << endl;
25  }else if(op == '*'){
26  cout << "Result = " << num1 * num2 << endl;
27  }else if(op == '/'){
28  cout << "Result = " << num1 / num2 << endl;
29  }
30  
31  
32}