Okay guys this is a subject that is a bit confusing to me... so just take it easy ...
Write a recursive function power(base, exponent) that when invoked returns
base ,exponent
for example, power(3,4 )= 3*3*3*3.Assume that exponent is an integer greater than or equal to 1.And the termination condition occurs when exponent is equal to 1 because base 1 = base..
Code:
#include <stdio.h>
#include <math.h>
int exponent ( int ,int ); //fucntion protoype
int main()
{
int cnt, result;
result = exponent (cnt, result );
for ( cnt =2; cnt <= 10; cnt++ ){
printf ("%d! = %d\n", cnt , result );
}
system("PAUSE");
return 0;
}
int exponent ( int a, int b )
{
if ( a <= 1 )
return 1;
else
return pow( (a*a),2);
}