In C++, the exp2() function is defined in the <cmath> or <math.h> header file and is used to calculate the base-2 exponential value of a given number. It computes the value of 2 raised to the power of the specified number.
The exp2() function accepts integer, float, double, and long double values as input and returns the result in floating-point form.
It has the following syntax.
x: It is the value of the exponent.
It returns, 2 raised to the power x.
Here, we are going to discuss several examples to demonstrate the List exp2() Function Function.
This example demonstrates how to calculate 2 raised to a positive power using the exp2() function.
Output:
Value of x is : 4 exp2(x) = 16
This example demonstrates how to calculate 2 raised to a negative power using the exp2() function.
Output:
Value of x is : -2 exp2(x) = 0.25
This example demonstrates how to calculate 2 raised to the power 0 using the exp2() function. The value of exp2(0) is always equal to 1.
Output:
Value of x is : 0 exp2(x) = 1
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India