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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
#include <iostream>
#include <math.h>
using namespace std;
// Function Prototypes
double addNum(int, int);
double diffNum(int, int);
double productNum(int, int);
double quoNum(int, int);
double remainNum(int, int);
double sqRoot(int);
double expFour(int);
void displayData();
void displayQuestion();
// Global Variables
int operand1 = 0;
int operand2 = 0;
int main()
{
displayQuestion(); // Function that asks for the operands
displayData(); // Function that displays all of the calculations
return 0; // Ends the program
}
// Adds operands
double addNum(int fn_operand1, int fn_operand2)
{
int fn_sum = fn_operand1 + fn_operand2;
return fn_sum;
}
// Subtracts operands
double diffNum(int fn_operand1, int fn_operand2)
{
int fn_diff = fn_operand1 - fn_operand2;
return fn_diff;
}
// Multiplys operands
double productNum(int fn_operand1, int fn_operand2)
{
int fn_product = fn_operand1 * fn_operand2;
return fn_product;
}
// Divides operands
double quoNum(int fn_operand1, int fn_operand2)
{
int fn_quo = fn_operand1 / fn_operand2;
return fn_quo;
}
// Remainder of operands
double remainNum(int fn_operand1, int fn_operand2)
{
int fn_remain = fn_operand1 % fn_operand2;
return fn_remain;
}
// Square Root of operand1
double sqRoot(int fn_operand1)
{
double fn_sqRoot = sqrt(fn_operand1);
return fn_sqRoot;
}
// Operand2 to the power of four
double expFour(int fn_operand2)
{
double fn_expFour = pow(fn_operand2, 4);
return fn_expFour;
}
// Displays operand questions
void displayQuestion()
{
cout << "Enter two integers to work with: ";
cout << "" << endl;
cout << "Operand1: ";
cin >> operand1;
cout << "" << endl;
cout << "Operand2: ";
cin >> operand2;
cout << "" << endl;
}
// Displays all answers
void displayData()
{
cout << "Sum: " << addNum(operand1, operand2) << endl;
cout << "" << endl;
cout << "Difference: " << diffNum(operand1, operand2) << endl;
cout << "" << endl;
cout << "Product: " << productNum(operand1, operand2) << endl;
cout << "" << endl;
cout << "Quotient: " << quoNum(operand1, operand2) << endl;
cout << "" << endl;
cout << "Remainder: " << remainNum(operand1, operand2) << endl;
cout << "" << endl;
cout << "Square Root of Operand1: " << sqRoot(operand1) << endl;
cout << "" << endl;
cout << "Operand2 ^ 4: " << expFour(operand2) << endl;
cout << "" << endl;
}
|