+ 1
How to use power in c++?
5 Answers
+ 7
#include <cmath>
pow(BASE, POWER);
Example:
int x = 5;
std::cout << pow(x, 2);
//output is 25
+ 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
}
+ 1
you can use pow function
+ 1
U must use pow()
0
ok
thx