C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Math exp2()The function computes the base - 2 exponential function of a given number. Suppose a number is 'x':exp2(x) = 2x Syntaxfloat exp2(float x); double exp2(double x); long double exp2(long double x); double exp2(integral x); Parameterx: It is the value of the exponent. Return valueIt returns, 2 raised to the power x. Example 1Let's see a simple example when the value of x is positive #include <iostream> #include<math.h> using namespace std; int main() { int x= 4; std::cout << "Value of x is : " <<x <<std::endl; cout<<"exp2(x) = "<<exp2(4); return 0; } Output: Value of x is : 4 exp2(x) = 16 Example 2Let's see a simple example when the value of x is negative. #include <iostream> #include<math.h> using namespace std; int main() { int x= -2; std::cout << "Value of x is : " <<x <<std::endl; cout<<"exp2(x) = "<<exp2(x); return 0; } Output: Value of x is : -2 exp2(x) = 0.25
Next TopicC++ Math Functions
|