**No math library function is allowed in this assignment. You HAVE TO use loop structure to do the calculation**
Write a C function named integerPower with the following prototype:
double integerPower(int base, int exponent);
This function shall compute and return the value of base exponent
The main function shall ask the user to enter the values for the two parameters (based and exponent) and then pass them to the function. The main function shall then display the returned value from the function.
#include <stdio.h> double integerPower(int base, int exponent); int main() { int base, exponent; printf("Enter base: "); scanf("%d", &base); printf("Enter exponent: "); scanf("%d", &exponent); printf("%d raised to the power of %d is %g\n", base, exponent, integerPower(base, exponent)); return 0; } double integerPower(int base, int exponent) { int i; double power = 1; for (i = 0; i < exponent; ++i) { power *= base; } return power; }
Get Answers For Free
Most questions answered within 1 hours.