In some programming languages, you can do exponentiation directly with the ^ operator. But while working on a problem, I found out that in C++, you have to use the pow function to do exponentiation. This article introduces two functions: pow, which does exponentiation for you, and sqrt, which takes square roots.

sqrtpow
What it doesSquare rootExponentiation
Librarymath.hmath.h
Code download: Box.net|4Shared|Dropbox|Google

1. Square root:

Format: result=sqrt(the number you want the square root of)

Example: get the square root of 9

#include
#includeusing namespace std;

int main()
{
    cout <

2. Exponentiation:

Format: result=pow(x, y)

Example: get 2 to the power of 4

#include
#include

using namespace std;

int main()
{
    cout <