Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- void SumProductDifference(int, int, int&, int&, int&);
- int Power(int a, int b);
- bool GoAgain();
- int main() {
- int a, b;
- int choice;
- int sum, product, difference;
- do
- {
- cout << "================================================" << endl;
- cout << "=====Welcome to AB Calculator 2016 Edition======" << endl;
- cout << "==== 1 - SumProductDifference Function ======" << endl;
- cout << "==== 2 - Power of Function ======" << endl;
- cout << "==== 3 - Quit ======" << endl;
- cout << "= Make A Selection: ======" << endl;
- cout << "================================================" << endl;
- cin >> choice;
- switch (choice) {
- case '1': SumProductDifference(a, b, sum, product, difference);
- break;
- case '2': Power(a, b);
- break;
- case '3':
- break;
- default:
- break;
- }
- return 0;
- } while (choice != 3);
- return 0;
- }
- bool GoAgain() {
- char answer;
- cout << "would you like to go again (y/n) ==> ";
- cin >> answer;
- return answer == 'y';
- }
- void SumProductDifference(int a, int b, int& s, int& p, int& d) {
- cout << "Enter two integers: ";
- cin >> a, b;
- s = a + b;
- p = a * b;
- d = a - b;
- cout << "The sum of " << a << " + " << b << " = " << s << endl;
- cout << "The product of " << a << " * " << b << " = " << p << endl;
- cout << "The difference of " << a << " - " << b << " = " << d << endl;
- }
- int Power(int a, int b) {
- int total = 1;
- int i;
- cout << "Enter a number: ";
- cin >> a;
- cout << "Raise this integer to the power of: ";
- cin >> b;
- for ( i = 1; i < b; i++) {
- total = total *b;
- }
- return total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement