C program to find the power ‘n’ of the given number ‘a’ : In this program we will find the power n of the given number.
Code for C program to find the power ‘n’ of the given number ‘a’
#include <stdio.h>
#include <conio.h>
int main()
{
int base, exponent;
long value = 1;
printf("Enter a base value:");
scanf("%d", &base);
printf("Enter an exponent value: ");
scanf("%d", &exponent);
while (exponent != 0)
{
value *= base;
--exponent;
}
printf("result = %ld", value);
return 0;
}
Output
Enter a base value:2
Enter an exponent value: 4
result = 16