#include <stdio.h>
// Function to calculate the power of a number
double power(double base, int exponent);
int main() {
// Input base and exponent from the user
double base;
int exponent;
printf("Enter the base: ");
scanf("%lf", &base);
printf("Enter the exponent: ");
scanf("%d", &exponent);
// Calculate and display the result
printf("%.2lf^%d = %.2lf\n", base, exponent, power(base, exponent));
return 0;
}
// Function to calculate the power of a number using recursion
double power(double base, int exponent) {
// Base case: when exponent is 0, return 1
if (exponent == 0) {
return 1;
}
// Recursive case: calculate power using recursion
else {
return base * power(base, exponent - 1);
}
}