Question: Question to be done in C. Use the three recursive functions discussed in class for raising a number to a power to compute (1.12)631. For

Question to be done in C. Use the three recursive functions discussed in class for raising a number to a power to compute (1.12)631. For each function, your program should print out the result of exponentiation and the number of times the function is called. Also print the average execution times. Below are the hint and recursive function.

double fpow(float a, int n) { if (n == 0) return 1; else { if( n % 2 == 0) { return fpow(a, n/2) * fpow(a, n/2); } else { return a * fpow(a, n/2) * fpow(a, n/2); } } } double fpww(float a, int n) { if (n == 0) return 1; else { double b = fpww(a, n/2); if( n % 2 == 0) { return b*b; } else { return a * b * b; } } } double fpwww(float x, int n) { float m; if (n == 0) return 1; if (n % 2 == 0) { m = fpwww(x, n / 2); return m * m; } else return x * fpwww(x, n - 1); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!