Dark Mode On/Off

# C Program To Find Power Of A Number Using Recursion

## Logic To Find The Power Of The Number Using Recursion:

• In this program by getting the input from the user in two forms a base number and exponent number,
• The base number is multiplied by the number of times of the exponent number,
• By using the if condition, the power of a number can be found, by multiplying the number by the number of times the exponent number is given and returns the value,

## C PROGRAM TO FIND POWER OF THE NUMBER USING RECURSION:

#include <stdio.h>

long power (int, int);

int main()
{
int exp, base;
long value;

printf("Enter The Number Base Number: ");
scanf("%d", &base);
printf("Enter The Exponent: ");
scanf("%d", &exp);
value = power(base, exp);
printf("%d^%d is %ld", base, exp, value);
return 0;
}

long power (int base, int exp)
{
if (exp)
{
return (base * power(base, exp - 1));
}
return 1;
}

## Output:

Want to learn coding?
Try our new interactive courses.
Over 20,000+ students enrolled.