#include <stdio.h>
int main()
{
int base, exponent, flag;
long int answer=1;
printf("Enter base number:");
scanf("%d", &base);
printf("Enter exponent number:");
scanf("%d", &exponent);
flag = exponent;
while (flag != 0)
{
answer = answer * base;
--flag;
}
printf("Power of %d to the %d =
%d", base, exponent, answer);
return 0;
} |
Output of the
Program:
Enter base number:2
Enter exponent number:5
Power of 2 to the 5
= 32
No comments:
Post a Comment