C Program to find power of a number using recursion

Simple C program to find power of a number using recursion: If number is 4 and its power that we have to find is 3 then program will print 64.
#include<stdio.h>
int FindPower(int n,int pow)
{
 if(pow==0)
 return 1;
 return n*FindPower(n,pow-1);
}
int main()
{
 int n,pow;
 printf("Enter a number: ");
 scanf("%d",&n);
 printf("Enter its power: ");
 scanf("%d",&pow);
 printf("%d power %d =",n,pow);
 printf("%d",FindPower(n,pow));
 return 0;
 
}



Popular posts from this blog