C Online Compiler
Example: C Program to Find Power of a Number using While loop
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Find Power of a Number using While loop #include <stdio.h> // It's the driver function int main() { int b, x; long long r = 1; // b - Base value, x - Exponent value, r - Result value printf("INPUT Base Number:: "); scanf("%d", &b); printf("\nINPUT Exponent Number:: "); scanf("%d", &x); // It will calculate the power of the base number while (x--) { r *= b; } // It will print the final output printf("\n\nOUTPUT:: %d^%d = %lld\n", b, x, r); return 0; }
3 4
Output
Clear
ADVERTISEMENTS