Power Function

Published on: August 13, 2010

In this video tutorial, I introduce the power function to you which you can use with the help of cmath. It's very convenient when you have to use exponents and it's higher than your normal squard or cubed or even to the 4th power.

This video provides a view of how to use the "pow" function in C++. The program I'm using is Visual Studio 2008 C++. If you have any requests just let me know and I'll get to it. If you want the actual code, also let me know and I'll send it your way.

Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.


//Programmer: Nazmus
//Program:  Pow
//Purpose:  To learn exponents in C++
//Website:  EasyProgramming.net 


using namespace std;

int main()
 cout << "Today we learn the Power Function." <<endl<<endl;

 float a, b, c;

 cout << "Please enter the base: ";
 cin >> a;

 cout << "Please input the exponent (to the power of): ";
 cin >> b;

 c = pow(a, b);

 cout << a << " to the power of " << b << " equals to " << c
  << '.' << endl << endl;