Exercise 9-1. Beginning C, I. Horton

A function with the prototype

double power(double x, int n);

should calculate and return the value of x^n. That is, the expression power(5.0, 4) will evaluate 5.0*5.0*5.0*5.0, which will result in the value 625.0.

Implement the power() function as a recursive function (so it should call itself) and demonstrate its operation with a suitable version of main().

exercise_9_1

This entry was posted in C. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s