C++ Programming Code Examples C++ > Mathematics Code Examples Compute power using pow() Function Compute power using pow() Function In this article, you will learn to compute power to a number manually, and by using pow() function. This program takes two numbers from the user (a base number and an exponent) and calculates the power. Power of a number = base^exponent #include <iostream> #include <cmath> using namespace std; int main() { float base, exponent, result; cout << "Enter base and exponent respectively: "; cin >> base >> exponent; result = pow(base, exponent); cout << base << "^" << exponent << " = " << result; return 0; }