Program to find power of any number in C++

bookmark

// Program to find power of any number
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  float base, expo;
  cout << "Input the base: ";
  cin >> base;
  cout << "Input the exponent: ";
  cin >> expo;
  float result = pow(base, exponent);
  cout << "Answer: " << result;
}

 

Output

Input the base: 2
Input the exponent: 4
Answer: 16