the question is pow(x,n)
double positivePower(double x,int n,double res)
{
if(n==0)
{
return res;
}
return positivePower(x,n-1,res*x);}
double negativePower(double x,int n,double res)
{
if(n==0)
{
return res;
}
return negativePower(x,n+1,res/x);
}
==33==ERROR: AddressSanitizer: stack-overflow on address 0x7ffd06232ff8 (pc 0x0000004017dc bp 0x7ffd06233000 sp 0x7ffd06233000 T0)
==33==ABORTING
Can anyone tell me why is it so. I had done my best to make it a tail recursion but still getting this error.