Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function, float pos_power(float base, int exponent); which returns the v

ID: 643038 • Letter: W

Question

Write a function, float pos_power(float base, int exponent); which returns the value of base raised to a positive exponent. For example, if base is 2.0 and exponent is 3, the function should return 8.0. If the exponent is negative, the function should return 0.

Another useful debugging technique is to put debug lines into your functions to show when it is called, with what values are passed to it, and when the function returns with what value is being returned. Try using this technique for your function pos_power(). Put a printf() that looks like:

as the first statement executed in your function. Put a printf() that looks like:

(or whatever your variable name is for the result) as the statement just before the function returns. Use #ifdef to allow these debug lines to be turned on and off. Turn debugging off when you hand in your programs. Write a driver, main(), to allow you to test the function. Put the driver in the file named driver3.c You can compile this program with the command:

Explanation / Answer

float power(float n, int p) // returns a float { float pow = 1; int i; for (i = 1; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote