+ 1
/Calculate X raised yo power Y using different methods while :do while :for
1 Answer
+ 2
Cool Mo,
You can also use the function in the cmath libraryâŠ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float x,y;
cin >> x >> y;
cout << pow(x, y);
return 0;
}
P.s: Your examples work with integers (although you use floats) - 2^2.5 (2 to the power of 2.5) will give the wrong result.