Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RedEdge967 committed Dec 7, 2021
1 parent ec2caca commit 3c6c816
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions power cal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#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;
}

0 comments on commit 3c6c816

Please sign in to comment.