Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void getData(int& num1, int& num2);
- void doTheMath(int num1, int num2, int& sum, int& difference, int& product, int& quotient, int& remainder);
- void displayResults(int num1, int num2, int& sum, int& difference, int& product, int& quotient, int& remainder);
- int main()
- {
- int num1;
- int num2;
- int sum;
- int difference;
- int product;
- int quotient;
- int remainder;
- getData(num1, num2);
- doTheMath(num1, num2, sum, difference, product,quotient,remainder);
- displayResults(num1, num2, sum, difference, product, quotient, remainder);
- return 0;
- }
- void getData(int& num1, int& num2)
- {
- cout << "Enter two intergers: ";
- cin >> num1;
- cin >> num2;
- }
- void doTheMath(int num1, int num2, int& sum, int& difference, int& product, int& quotient, int& remainder)
- {
- sum = num1 + num2;
- difference = num1 - num2;
- product = num1 * num2;
- if (num2 != 0) {
- remainder = num1 % num2;
- quotient = num1 / num2;
- }
- }
- void displayResults(int num1, int num2, int& sum, int& difference, int& product, int& quotient, int& remainder)
- {
- if (num2 == 0)
- {
- cout << "Here are the results:\n\nThe sum of " << num1 << " and " << num2 << " is " << sum;
- cout << "\nThe difference, (" << num1 << " minus " << num2 << ") is " << difference;
- cout << "\nThe product of " << num1 << " and " << num2 << " is " << product;
- cout << "\nCannot divide by zero\n\n";
- }
- if (num2 != 0)
- {
- cout << "Here are the results:\n\nThe sum of " << num1 << " and " << num2 << " is " << sum;
- cout << "\nThe difference, (" << num1 << " minus " << num2 << ") is " << difference;
- cout << "\nThe product of " << num1 << " and " << num2 << " is " << product;
- cout << endl << num1 << " divided by " << num2 << " is " << quotient << " with a remainder of " << remainder << "\n\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement