Slide 17
Slide 17 text
Your turn
Write a function that takes 2 parameters, number and exponent,
and returns number raised to the power of exponent.
#include
int power(int number, int exponent); // function prototype
int main(void) {
int x = 2;
int third = power(x, 3);
printf("%d raised to the power of %d is %d\n", x, 3, third);
int fifth = power(x, 5);
printf("%d raised to the power of %d is %d\n", x, 5, fifth);
return 0;
}
int power(int number, int exponent) {
// ...
}