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
|
#include <iostream>
using namespace std;
bool compute(int one, int two, int & sum, int & product, double& quotient); //intializing prototype
void main()
{
int one, two, sum, product;
double quotient;
quotient = 0;
cout << "Enter two integers: ";
cin >> one >> two;
if ( compute( one, two, sum, product, quotient) )
{
cout << "\nSum: " << sum << "\nProduct: " << product
<< "\nQuotient: "<< quotient << endl;
}
else
cout << "\nSum: " << sum << "\nProduct: " << product
<<"\nThe quotient cannot be computed.\n" ;
system("pause");
return ;
}
bool compute(int a, int b, int& sum, int & product, double& divided)
{
bool result = true;
sum = a + b;
product = a * b;
if (b>0)
{
divided = (a)/(b);
}
else
result = false;
return result;
}
/*
Enter two integers: 1 2
Sum: 3
Product: 2
Quotient: 0
Press any key to continue . . .
*/
|