Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- cout << "#### Welcome to calc ####" << endl;
- cout << "Enter first number" << endl;
- int num1;
- cin >> num1;
- string op;
- cout << "Enter operator (+, -, *, /)" << endl;
- cin >> op;
- int num2;
- cout << "Enter second number" << endl;
- cin >> num2;
- if(op == "+"){
- cout << "Answer is: " << num1 + num2 << endl;
- }else if (op == "-"){
- cout << "Answer is: " << num1 - num2 << endl;
- }else if (op == "*"){
- cout << "Answer is: " << num1 * num2 << endl;
- }else if (op == "/"){
- cout << "Answer is: " << (num1/num2) << endl;
- }else{
- cout << "Invalid" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement