## Program to compute power of a given number x raised to y

October 2, 2012
Comments Off on Program to compute power of a given number x raised to y By admin

**Recursion**

**Program to compute power of a given number x raised to y**

#include <stdio.h>

#include <conio.h>

int power(int x,int n)

{

if(n==0)

return 1;

else

return(x * power(x,n-1));

}

void main()

{

int x,n,res;

clrscr();

printf(“nEnter base?”);

scanf(“%d”,&x);

printf(“nEnter exponent?”);

scanf(“%d”,&n);

res=power(x,n);

printf(“Power of %d raised to %d is %d”,x,n,res);

getch();

}

Post Views:
998