C++ Math pow()

Last Updated : 16 May 2026

Math pow() Function

In C++, the pow() function is defined in theheader file and is used to calculate the power of a given number. It raises a base value to the power of the specified exponent and returns the computed result. The pow() function supports integer, float, double, and long double values.

Consider a base 'b' and exponent 'e'.

Power=be

Syntax

It has the following syntax.

Note: If any argument is of long double type, then the return type is promoted to long double. If not, then the return type is promoted to double.

Parameters

b: 'b' is the number, whose power is to be calculated.

e: 'e' is the exponent.

Return value

It returns the base 'b'raised to the power 'e'.

Examples of Math pow() Function

Here, we are going to discuss several examples to demonstrate the Math pow() Function

Example 1: Calculate the Power of Integer Values Using pow()

This example demonstrates how the pow() function calculates the power when both the base and exponent are integer values.

Output:

Power of a given number is :16

Example 2: Calculate the Power of a Floating-Point Base Using pow()

This example demonstrates how the pow() function calculates the power when the base value is a floating-point number and the exponent is an integer.

Output:

Power of a given number is :64

Example 3: Calculate the Power When Both Base and Exponent are Floating-Point Values

This example demonstrates how the pow() function calculates the power when both the base and exponent are floating-point values.

Output:

Power of a given number is :4