Question: Given the following four functions, how would they be put into a main function (int main()). Use cout and cin statements. (C++ LANGUAGE ONLY PLEASE)
Given the following four functions, how would they be put into a main function (int main()). Use cout and cin statements. (C++ LANGUAGE ONLY PLEASE)
1.
float computeRoot(float root, int index) { float tp, mid; float low = 0; float high = root;
do { mid = (low + high) / 2; if (Power(mid, index) > root) { high = mid; } else { low = mid; }
mid = (low + high) / 2; tp = (computePower(mid, index) - root);
if (tp < 0) {//grab absolute value tp = tp * (-1.0); } } while (tp > .000005);//accuracy of our root
return mid; }
2.
float computePower(float x, int n) { float numProduct = 1; int i;
for (i = 0; i < n; i++) { numProduct = numProduct * x; }
return numProduct; }
3.
int computeGCD(int a, int b) { while (a != b) { if (a > b) { a = a - b; } else { b = b - a; } }
return a; }
4.
int computeLCM(int a, int b) { int tmp_lcm;
tmp_lcm = ((a * b) / GCD(a, b));
return tmp_lcm; }
int computeMod(int num1, int num2) {
float computePerc(float, float) { return 0.0f; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
