C++ Raise to Power Function

beginner c++11 math

#include <cmath>

The C++ Standard Library provides the pow function which raises a base to the power of an exponent. For example:

#include <cmath>
#include <iostream>

int main() {
  auto result = std::pow(3, 8);

  std::cout << result << "\n";

  auto result2 = std::pow(3.141592f, 8.3f);

  std::cout << result2 << "\n";
}
6561
13376.5

For more C++ By Example, click here.