Computer Science, asked by yuvrajsingh4399, 1 year ago

Write a ‘c' program to find the power of number using function

Answers

Answered by hemanth990810
0

#include <stdio.h>

int main()

{

int base, exponent;

long long result = 1;

printf("Enter a base number: ");

scanf("%d", &base);

printf("Enter an exponent: ");

scanf("%d", &exponent);

while (exponent != 0)

{

result *= base;

--exponent;

}

printf("Answer = %lld", result);

return 0;

}

Output

Enter a base number: 3

Enter an exponent: 4

Answer = 81

Similar questions