Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- char op;
- int num1, num2;
- int sum;
- int product;
- int difference;
- int quotient;
- answer = //This doesnt equal anything. It'll be an error.
- sum = num1 + num2;
- product = num1 * num2;
- difference = num1 - num2 ;
- quotient = num1 / num2;
- cout << "choose operation";
- cout << "+ addition" ;
- cout << "- subtract" ;
- cout << " * multiply" ;
- cout << " / divide" ;
- //You are not cin -ing anything. Theres no way for the user to input in an operator
- //no default case. What if the user enters *&^Y*YGYIUG as their operator?
- switch ( op )
- {
- case '+' :
- cout << "Enter an integer";
- cin >> num1;
- cout << "Enter another integer";
- cin >> num2;
- cout << num1 + num2 ;
- cout << sum;
- cout << endl;
- break;
- case '-' :
- cout << "Enter an integer" ;
- cin >> num1 ;
- cout << "Enter another integer";
- cin >> num2 ;
- cout << num1 - num2;
- cout << difference;
- cout << endl;
- break;
- case '*' :
- cout << "Enter an integer" ;
- cin >> num1 ;
- cout << "Enter another integer";
- cin >> num2 ;
- cout << num1 * num2;
- cout << product;
- cout << endl;
- break;
- case '/' :
- cout << "Enter an integer" ;
- cin >> num1 ;
- cout << "Enter another integer";
- cin >> num2 ;
- cout << num1 / num2;
- cout << quotient;
- cout << endl;
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement