Original Post
I'm trying to build a function that does the same job as pow(x,y) the idea of the function is to learn recursion, however its not working, anyone now why?
Cheers
Edited by - StephenNitro on 10/15/00 2:59:08 PM
int power( int base , int exponent )
{
if ( exponent == 1)
return 1 ;
else
return base *= power( base , exponent - 1 );
}
int main( )
{
cout << power( 3 , 4 ) << endl;
cout << pow( 3, 4 ) << endl; // Just for testing results
return 0;
}
|