Power or Exponential in C+++

Sometimes you need to   use exponencial or power , there is a library functions named pow().
http://russelltheprogrammer.com/ :: Source
Some example in c++ given below:

double pow( double x, int y ); // C++ only
float pow( float x, float y ); // C++ only
float pow( float x, int y ); // C++ only
long double pow( long double x, long double y ); // C++ only
long double pow( long double x, int y ); // C++ only
Even you can also use pow() function as below method:
double pow( double x, double y );
float powf( float x, float y );
long double powl( long double x, long double y );
Let’s See Some Code in C++:
#include <bits/stdc++.h>
using namespace std;
int main()
{
double x = 7.0, y = 9.0, z;
z = pow( x, y );
printf( “%.1f to the power of %.1f is %.1f\n”, x, y, z );
return 0;
}
Output:
7.0 to the power of 9.0 is 40353607.0


Comments