Power function using recurssion in c

Leave a Comment
#include<stdio.h>
#include<conio.h>
int power(int x,int y)
{
if(y==0)
return 1;
else
return (x*power(x,y-1));
}


int main()
{
int x,y;
printf("\n Enter the value of x & y :");
scanf("%d%d",&x,&y);
printf("Value of %d to the power %d=%d",x,y,power(x,y));
getche();
return 0;
}

0 comments: