Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- char symbol;
- double a, b, answer;
- cout << "Enter your first number: ";
- cin >> a;
- cout << "Enter your second number: ";
- cin >> b;
- cout << "Enter the symbol of the operation you wish to perform.\n " << endl;
- cout << "Symbols:\n " << endl;
- cout << "Addition : +\n \nSubtraction: -\n \nMultiplication: *\n \nDivision: /" << endl;
- cout << "-----------------" << endl;
- cin >> symbol;
- if(symbol == '/' && b == 0){
- cout << "Are you trying to implode the universe? No? Then don't divide by zero.";
- }
- else if(symbol == '+'){
- answer = a + b;
- cout << " \nThe answer is: " << answer;
- }
- else if(symbol == '-'){
- answer = a - b;
- cout << " \nThe answer is: " << answer;
- }
- else if(symbol == '*'){
- answer = a * b;
- cout << " \nThe answer is: " << answer;
- }
- else if(symbol == '/'){
- answer = a / b;
- cout << " \nThe answer is: " << answer;
- }
- int x;
- cin>>x;
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement