#include <cmath>
pow(base, exponent);
/* pow example */
#include <stdio.h> /* printf */
#include <math.h> /* pow */
int main ()
{
printf ("7 ^ 3 = %f
", pow (7.0, 3.0) ); //7 ^ 3 = 343.000000
printf ("4.73 ^ 12 = %f
", pow (4.73, 12.0) ); //4.73 ^ 12 = 125410439.217423
printf ("32.01 ^ 1.54 = %f
", pow (32.01, 1.54) ); //32.01 ^ 1.54 = 208.036691
return 0;
}
/* pow example */
#include <stdio.h> /* printf */
#include <math.h> /* pow */
int main ()
{
printf ("7 ^ 3 = %f
", pow (7.0, 3.0) );
printf ("4.73 ^ 12 = %f
", pow (4.73, 12.0) );
printf ("32.01 ^ 1.54 = %f
", pow (32.01, 1.54) );
return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll power(ll a,ll b){
ll ans = 1;
while(b--){
ans *= a;
}
return ans;
}
int main(){
ll x,y;
cin >> x >> y;
ll x_power_y = power(x,y);
cout << x_power_y << endl;
}
double result = pow(x, y);
// CPP program to illustrate
// power function
#include <bits/stdc++.h>
using namespace std;
int main()
{
double x = 6.1, y = 4.8;
// Storing the answer in result.
double result = pow(x, y);
// printing the result upto 2
// decimal place
cout << fixed << setprecision(2) << result << endl;
return 0;
}
template<class T>T Pow(T n,T p)
{
T res = n;
for(T i = 1; i < p; i++)
res *= n;
return res;
}
//Example: Pow(2,3) = 8
In C++, pow(a, b) = a^b
Code Example |
---|
Cpp :: icon on win32 button |
Cpp :: is vowel c++/c |
Cpp :: simple interest rate |
Cpp :: converter python to c++ code |
Cpp :: split date and time in a column in db browser |
Cpp :: sum of 2 arrays c++ |
Cpp :: void does not a name a type in cpp |
Cpp :: c++ sleep function |
Cpp :: http://dcnet.ddns.ma/Connecter_Tuteur |
Cpp :: write c++ code using glbegin and gland() function |
Cpp :: how to initialize a vector in c++ |
Cpp :: auto i cpp |
Cpp :: c++ array on heap |
Cpp :: how a function gives a pointer as parameter c++ |
Cpp :: cpp tutorial |
Cpp :: std::string remove last |
Cpp :: function overloading in cpp |
Cpp :: c++ influenced |
C :: c colour text |
C :: rename c |
C :: pygame draw transparent rectangle |
C :: react-textfit |
C :: send http request in C |
C :: Prime Number Check Program in C |
C :: how to read character from a string in c |
C :: servo motor arduino |
C :: how to login to another user in powershell |
C :: how to sort assending in c |
C :: comment c |
C :: initialize array c |