What is exp2() in C?

The exp2() function is used to compute 2 raised to the power of x in C.

Mathematical Representation

Library

#include<math.h>

Syntax

Below is the declaration of the exp2() function,

double exp2(double x);

where x is the exponent passed as a parameter to the function. The function returns 2 raised to the power of x as a double value.

Code

#include <math.h>
#include <stdio.h>
int main()
{
printf("Value of 2 raised to power 3: %f", exp2(3));
printf("\nValue of 2 raised to power -2: %f", exp2(-2));
return 0;
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved