exponent c++ 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: how to write something in power of a number in c++
#include <iostream>
#include <cmath>
using namespace std;
int main(){
cout<<pow(10,2);
return 0;
}
Example 3: exponents c++
pow(base, exponent);
example:
#include <iostream>
#include <cmath>
int main ()
{
int y;
int x =10;
y = pow(x,2);
}
Example 4: 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;
}