Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- // Introduction
- cout << "Welcome to calculator" << endl;
- cout << "" << endl; // Empty Space
- cout << "" << endl; // Empty Space
- cout << "Made by *enter_name*" << endl;
- cout << "" << endl; // Empty Space
- cout << "" << endl; // Empty Space
- // Calculator
- int num1; // Number 1 Variable
- int num2; // Number 2 Variable
- char opr; // Operation Variable
- // Number 1
- cout << "Enter your first number : ";
- cin >> num1;
- cout << endl;
- cout << "" << endl; // Empty Space
- // Number 2
- cout << "Enter your second number : ";
- cin >> num2;
- cout << endl;
- cout << "" << endl; // Empty Space
- // Operation
- cout << "Enter your operation ( *, -, +, / ) : ";
- cin >> opr;
- cout << endl;
- cout << "" << endl; // Empty Space
- // Fetching answers
- cout << num1 << " " << opr << " " << num2 << " = ";
- switch (opr) {
- case '+':
- cout << num1 + num2 << endl;
- break;
- case'-':
- cout << num1 - num2 << endl;
- break;
- case'*':
- cout << num1 * num2 << endl;
- break;
- case'/':
- if (num2 != 0)
- cout << num1 / num2 << endl;
- else
- cout << "ERROR \nCannot divide by zero" << endl;
- break;
- default:
- cout << "Illegal operation" << endl;
- }
- // Makes sure the Program doesn't end
- string Endless;
- cin >> Endless;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement