C Examples Power Number
π
2026-06-20 | π C
# C Programming Examples - Calculate the N-th Power of a Number
[ C Programming Examples](#)
Calculate the N-th power of a number, for example: 2^3, where 2 is the base and 3 is the exponent.
## Example - Using while
#includeint main(){int base, exponent; long long result = 1; printf("Base: "); scanf("%d", &base); printf("Exponent: "); scanf("%d", &exponent); while(exponent != 0){result *= base; --exponent; }printf("Result: %lld", result); return 0; }
Output:
Base: 2Exponent: 3Result: 8
## Example - Using pow() function
#include#include