Tuesday 7 May 2013

Program In C To Calculate exponential power i.e. e(x,y) using recursion


#include<stdio.h>
#include<conio.h>
int fun( int x, int y)
{ int z;
if(y==0)
return 1;
else
z=x*fun(x,y-1);
return z;
}
void main()
{ int a,b,c;
printf("Enter base: ");
scanf("%d",&a);
printf("Enter exponent: ");
scanf("%d",&b);
c=fun(a,b);
printf("Answer Is: %d",c);
getch();
}

No comments:

Post a Comment