pow function in cpp code example
Example 1: pow c++
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double base, exponent, result;
base = 3.4;
exponent = 4.4;
result = pow(base, exponent);
cout << base << "^" << exponent << " = " << result;
return 0;
}
Example 2: pow in cpp header file
#include<cmath>
pow(a,b)
Example 3: c++ power
#include <stdio.h>
#include <math.h>
int main ()
{
printf ("7 ^ 3 = %f\n", pow (7.0, 3.0) );
printf ("4.73 ^ 12 = %f\n", pow (4.73, 12.0) );
printf ("32.01 ^ 1.54 = %f\n", pow (32.01, 1.54) );
return 0;
}
Example 4: pow c++
template<class T>T Pow(T n,T p)
{
T res = n;
for(T i = 1; i < p; i++)
res *= n;
return res;
}
Example 5: powers of 2 in cpp
int main() {
int ans = 1 >> n;
}
void power(int x, int y) {
int ans = 1;
for (int i = 0; i < y; i++) {
ans *= x;
}
return ans;
}
Example 6: pow() c
[Mathematics] xy = pow(x, y) [In programming]