Raise Number To Power using Recursion C Program

By | December 18, 2015

C Program To Raise Number To Power using Recursion

Learn How To Raise Number To Power in C Programming Language using Recursion Technique. It is important that we should know How A For Loop Works before getting further with this C Program Code Tutorial.

Example

23 = 8

C Program To Raise Number To Power with Recursion

#include<stdio.h>

int power_recursion(int base_num, int pow_num)
{
    if(pow_num == 0)
        return 1;
    else
        return (base_num * power_recursion(base_num, pow_num - 1));
}

int main()
{
    int base_num, pow_num;
    int result;
    printf("Enter the Number: \t");  
    scanf("%d", &base_num);
    printf("Enter the Power: \t");
    scanf("%d", &pow_num);
    result = power_recursion(base_num, pow_num);
    printf("\nResult =  %d\n", result);
    printf("\n");
    return 0;
}

Also Read: C Program To Raise An Integer To Power using For Loop

 

Output

C Program To Raise Number To Power using Recursion Method

In case you get any Compilation Errors with this C Program To Raise Integer To Power of any other Integer or if you have any doubt about it, let us know about it in the Comment Section below.

Let's Discuss