C++ Online Compiler
Example: C++ Program to Find Power of a Number using For loop
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ Program to Find Power of a Number using For loop #include <iostream> using namespace std; int main() { int b, x, i; long long r = 1; // b - Value of the base number // x - Value of the exponent number // r - Value of the result value cout << "-----Enter the input of base number-----\n"; cin >> b; cout << "\n-----Enter the input of exponent number-----\n"; cin >> x; for (i = x; i > 0; i--) { r *= b; } cout << "\nThe calculation of the power of N number is " << b << "^" << x << " = " << r << "\n"; return 0; }
5 4
Output
Clear
ADVERTISEMENTS