Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

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

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();
}

Comments are closed
x Close

Like Us On Facebook

You cannot copy content of this page.