Kimberly Martar
2013-04-16 14:12:38 UTC
This program will ask the user to enter two numbers then ask
if they want to multiply or add the two numbers and then
the program will execute and display the results using a
void function.*/
#include
#include
#include
using namespace std;
// function prototype
void product(double num1, double num2)
{ cout << product;
}
void sum(int num1, int num2)
{
cout << sum;
}
int main()
{
double num1, num2, product;
int num1, num2, sum;
char choice, again;
//Asks the user if they want to add or multiply and recieves input.
do{
cout << "What would i like to do add or multiply?\n";
cout << "Please press 'a' for add and 'm' for multiply and press enter.\n";
cin >> choice;
if ((choice == 'a') || (choice == 'A'))
// Add
{cout << "Enter the two numbers you would like to add\n";
cout << "and I will tell you the answer: ";
cin >> num1 >> num2;
sum = num1 + num2;
sum;
}
// Multiply
else ((choice == 'm') || (choice == 'M'));
cout << "Enter the two numbers you would like to multiply\n";
cout << "and I will tell you the snwer; ";
cin >> num1 >> num2;
product = num1 * num2;
product;
// Asks the user if they would like to try again.
cout << "Would you like to try again? Type 'y' yes and 'n' for no. ";
cin >> again;
}while ((again == 'y') || (again == 'Y'));
cout << endl;
system("pause");
return 0;
}