/* * Example program that demonstrates function * to compute the power of a number. * Sara Sprenkle 06.20.05 */ #include /* * Raise n to the exp power */ double power( double n, int exp ) { double value = 1; int i; for( i=0; i < exp; i++ ) { value *= n; } return value; } int main() { double number; int exponent; printf("Give me a number and the power: "); scanf("%lf %d", &number, &exponent); // Testing the power function /* power( 2, 3); power (2.5, 3); */ printf("%lf^%d = %lf \n", number, exponent, power( number, exponent) ); return 0; }