C Program to find Power of a Number
Learn C - C tutorial - c program to find power of a number - C examples - C programs
C Program to find Power of a Number
- The power of a number denotes how many times to use the number in a multiplication.
- It is mentioned as a small number to the right and above the base number.
- In this example: 82 = 8 × 8 = 64.
Sample Code
#include <stdio.h>
int main()
{
int base=4, exponent=7;
long long result = 1;
printf("Base Number:6\n ");
printf("Exponent:6\n ");
while (exponent != 0)
{
result *= base;
--exponent;
}
printf("Answer = %lld", result);
return 0;
}
Output
Base number:4
Exponent:7
Answer = 16384