Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void calculator() {
- int num1;
- int num2;
- string method;
- cout << "Enter a number: ";
- cin >> num1;
- cout << "Enter another number: ";
- cin >> num2;
- cout << "Add, subtract, multiply, or divide: ";
- cin >> method;
- if (method == "+" || method == "add")
- {
- cout << num1 + num2;
- }
- else if (method == "-" || method == "subtract")
- {
- cout << num1 - num2;
- }
- else if (method == "*" || method == "multiply")
- {
- cout << num1 * num2;
- }
- else if (method == "/" || method == "divide")
- {
- cout << num1 / num2;
- }
- else
- {
- cout << "Invalid form of math!";
- }
- cout << "\n";
- return calculator();
- }
- int main()
- {
- calculator();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement