> Why does not my programwork?

Why does not my programwork?

Posted at: 2014-12-18 
you are defining power() inside main

you cannot have nested functions

#include

#include

double power(double x, int n) {

int i ;

double result = 1.0;

for (i = 0; i
result *= x;

return result;

}

int main(void){

int k;

for(k=0;k<=5;k++)

printf("2^%d =%f \n",k,power(2.0,k));

return 0;

}

Write a function double power(double x, int n) that will compute x^n, the nth power of x. Check to see that it computes 3.5^7 correctly.

My code:

#include

#include

int main(void){

double power(double x, int n) {

int i ;

double result = 1.0;

for (i = 0; i <=n; ++i)

{

result *= x;

}

return result;

}

return 0;

}

How to print it ?