Writ a program to calculate power using recursion
Answers
Answered by
1
Explanation:
#include <stdio.h>
int power(int n1, int n2);
int main() {
int base, a, result;
printf("Enter base number: ");
scanf("%d", &base);
printf("Enter power number(positive integer): ");
scanf("%d", &a);
result = power(base, a);
printf("%d^%d = %d", base, a, result);
return 0;
}
int power(int base, int a) {
if (a != 0)
return (base * power(base, a - 1));
else
return 1;
}
Answered by
0
Answer:
Your answer is given in the following link:
Explanation:
https://www.programiz.com/c-programming/examples/power-recursion
Jai Hind
Jai Bharat
Similar questions
Math,
22 days ago
Business Studies,
22 days ago
Math,
1 month ago
World Languages,
9 months ago
Math,
9 months ago