1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <iostream>
using namespace std;
void showMenu ();
int getOption();
int getNumbers();
int addNumbers();
int divideNumbers();
int subtractNumbers();
int multiplyNumbers();
void displayResults();
void showMenu ()
{
cout<<" 1. Select 1 to add two numbers."<<endl;
cout<<" 2. Select 2 to divide two numbers. " <<endl;
cout<<" 3. Select 3 to subtract two number. " <<endl;
cout<<" 4. Select 4 to multiply two number. " <<endl;
}
int getOption (int selection)
{
cin>>selection;
return selection;
}
void getNumbers(int& num1, int& num2)
{
cout<<"Enter two numbers: ";
cin>>num1 >>num2;
}
int addNumbers(int num1, int num2, int& sum)
{
sum=num1+num2;
return sum;
}
int divideNumbers(int num1, int num2, int& sum)
{
sum=num1/num2;
return sum;
}
int subtractNumbers(int num1, int num2, int& sum)
{
sum=num1-num2;
return sum;
}
int multiplyNumbers(int num1, int num2, int& sum)
{
sum=num1 * num2;
return sum;
}
void displayResults(int num1, int num2, int& sum)
{
cout<<num1 << " + " <<num2 << " = " <<sum <<endl;
}
int main ()
{
int a=0;
int num1;
int num2;
int Result;
showMenu();
getOption(a);
getNumbers(num1, num2);
addNumbers(num1, num2, Result);
divideNumbers(num1, num2, Result);
subtractNumbers(num1, num2, Result);
multiplyNumbers(num1, num2, Result);
displayResults(num1, num2, Result);
system("pause");
}
|