C Program to Find Sum of Digits of a Number using Recursion
C Program to calculate a Number raised to the Power of N using Recursion
Below is a program to calculate the result of a given number, raised to the power of n using recursion.
Source code:
#include
// function prototype declaration
int power(int n1, int n2);
int main()
{
int base, exp;
printf("Enter base number: ");
scanf("%d", &base);
printf("\n\nEnter Power factor: ");
scanf("%d", &exp);
printf("\n\n\n\t\t\t%d^%d = %d", base, exp, power(base, exp));
return 0;
}
int power(int b, int e)
{
if(e == 0)
return 1;
return (b*power(b, e-1));
}
All Chapters — C programming
Similar Questions
From Recursive program in c · C programming
Program to find Palindrome using Recursion
C Program to Find whether a Number is Prime or Not using Recursion
Program to find Factorial of a Number using Recursion
C Program to find GCD of two Numbers using Recursion
C Program to Find Sum of N Numbers using Recursion
Program to print Fibonacci Series using Recursion
C Program to Print Binary Equivalent of an Integer using Recursion