Program:

#include<stdio.h>
int getPower(int base,int exponent)
{
    if(exponent == 0) return 1;
    return base * getPower(base,exponent-1);
}
int main()
{
    int base, exponent,z;
    printf("Enter base and exponent: ");
    scanf("%d %d", &base, &exponent);
    z = getPower(base,exponent);
    printf("Result = %d",z);
}

Output:

Enter base and exponent: 2 5
Result = 32

Leave a Reply

Your email address will not be published. Required fields are marked *