Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a program to calculate the power of a number using recursion.

Hard

Problem Statement

Implement a program to calculate the power of a number using recursion.

Sample Input

int base = 2; int exp = 3;

Sample Output

2 raised to the power 3: 8

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> int power(int base, int exp); int main() { // Logic to demonstrate power calculation return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
int base = 2; int exp = 3;
Expected Output
2 raised to the power 3: 8