Question: Do problem 18 in section 3.9 of the text. Put your function pos_power() in the file exponent.c and the prototype in the file exponent.h. Another

Do problem 18 in section 3.9 of the text. Put your function pos_power() in the file exponent.c and the prototype in the file exponent.h.

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:

 printf("debug:Enter pos_power: base = %f exponent= %d ", base, exponent); 

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

 printf("debug:Exit pos_power: result = %f ", value); 

(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:

 cc driver3.c exponent.c 

18. 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.

PLEASE WRITE IN C NOT C++

PLEASE INCLUDE POTOTYPE AND POS_POWER() FUNCTION

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!