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 recursion function will calculate the power of the base number long long FindPow(int b, int e, long long r) { if (e > 0) { e--; r *= b; FindPow(b, e, r); } else return r; } // It's the driver function int main() { int b, x; // b - Base value, x - Exponent value printf("INPUT Base Number:: "); scanf("%d", &b); printf("\nINPUT Exponent Number:: "); scanf("%d", &x); // It will print the final output printf("\n\nOUTPUT:: %d^%d = %lld\n", b, x, FindPow(b, x, 1)); return 0; }
4 5
Output
Clear
ADVERTISEMENTS