C++ Online Compiler
Example: C++ program to find the power of any number
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to find the power of any number #include <iostream> using namespace std; int main() { int b, e, r = 1, i = 1; // b = base // e = exponent // r = result // i = looping incremental cout << "Enter the base & exponent values::\n"; cin >> b >> e; // finding power of base value by equiping exponent value while(i <= e) { r *= b; i++; } // Output cout << "\nResult:: " << b << "^" << e << " = " << r; return 0; }
5 7
Output
Clear
ADVERTISEMENTS