Teacher gave a question today to find Base is 2 and power is 3. so that Answer should be 8. so to find that she told us to use Recursion and do it. i done it in the normal way. but when i do it in the Recursion way. one error coming saying too Few Parameters

please check


int multi(int,int);

int x=0,y=0;

printf("Enter Your Base Number:");

printf("Enter the Power Number:");

printf("The power of %d is %d",x,multi(x,y));


int multi (int x, int y)
int ans=0;

	 return 1;

	 return ans;


thanks my bad. in my coding i have put if(y<=1) it should be ( y<1) only . no equal sign.

thanks guys. thanks for the quick reply

The program you have written using recursion is logically wrong..

You have written the code if (y<=1) return=1
How can 2 power -1 will be equal to one..

So correct your program first and then see the results..

i agree. i thought about including that in my original answer, but decided to stick to the question as presented. some of the posters here (not necessarily this one) sort of implode if you throw too much at them.

anyhow... yeah, change your answer variable to type "double" , use the absolute value of the power to calculate the answer, and then throw this in at the end: if (pow<0) ans = 1.0/ans; pretty simple, really.


This question has already been answered. Start a new discussion instead.