C Online Compiler
Example: C Program to Find Power of a Number using Recursion
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find Power of a Number using Recursion #include <stdio.h> // This will find the power of a number // Using the recursion int CalculatePower(int b, int e) { if (e != 0) return (b * CalculatePower(b, e - 1)); else return 1; } // It's the driver code int main() { int base, exponent; printf("Enter the Base & Exponent values:\n"); scanf("%d%d", &base, &exponent); printf("\nResult: %d^%d = %d\n", base, exponent, CalculatePower(base, exponent)); return 0; }
9 5
Output
Clear
ADVERTISEMENTS