+ 1

How to use power in c++?

15th Aug 2016, 4:26 PM
Lavnish
Lavnish - avatar
5 Réponses
+ 7
#include <cmath> pow(BASE, POWER); Example: int x = 5; std::cout << pow(x, 2); //output is 25
15th Aug 2016, 6:06 PM
Cohen Creber
Cohen Creber - avatar
+ 4
Here is a sample program: #include <iostream> #include <cmath> using namespace std; int main(){ int b = 3; int p = 2; cout << pow(b,p); //base:3 pow:2 //output is 9 cout << endl; //change line b=4; p=3; cout << pow(b,p); //base:4 pow:3 //output is 64 }
17th Aug 2016, 2:01 PM
GTimo
GTimo - avatar
+ 1
you can use pow function
15th Aug 2016, 6:04 PM
Tushar Chetan
Tushar Chetan - avatar
+ 1
U must use pow()
16th Aug 2016, 5:01 AM
ashvinee
ashvinee - avatar
0
ok thx
16th Aug 2016, 4:58 AM
Lavnish
Lavnish - avatar