Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int Add(int, int);
- int Substract(int, int);
- int Multiply(int, int);
- int Divide(int, int);
- int main() {
- int firstnum, secondnum;
- char arithmetic_operations;
- cout << "Enter first number: ";
- cin >> firstnum;
- cout << "Enter second number: ";
- cin >> secondnum;
- cout << "Enter Arithmetic Operations (+, -, *, /): ";
- cin >> arithmetic_operations;
- if (arithmetic_operations == '+')
- cout << firstnum << " + " << secondnum << " = " << Add(firstnum, secondnum) << endl;
- else if (arithmetic_operations == '-')
- cout << firstnum << " - " << secondnum << " = " << Substract(firstnum, secondnum) << endl;
- else if (arithmetic_operations == '*')
- cout << firstnum << " * " << secondnum << " = " << Multiply(firstnum, secondnum) << endl;
- else if (arithmetic_operations == '/')
- cout << firstnum << " / " << secondnum << " = " << Divide(firstnum, secondnum) << endl;
- else
- cout << "You typed an invalid arithmetic operations!\n";
- return 0;
- }
- int Add(int firstnum, int secondnum) {
- return firstnum + secondnum;
- }
- int Substract(int firstnum, int secondnum) {
- return firstnum - secondnum;
- }
- int Multiply(int firstnum, int secondnum) {
- return firstnum * secondnum;
- }
- int Divide(int firstnum, int secondnum) {
- return firstnum / secondnum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement