1#include <iostream>
2#include <cmath>
3using namespace std;
4int main ()
5{
6 double base, exponent, result;
7 base = 3.4;
8 exponent = 4.4;
9 result = pow(base, exponent);
10 cout << base << "^" << exponent << " = " << result;
11 return 0;
12}
1pow(base, exponent); //must #include <cmath> to use pow()
2
3example:
4
5#include <iostream>
6#include <cmath> //must include this library
7
8int main ()
9{
10 int y;
11 int x =10;
12 y = pow(x,2); // y = x^2
13}
1/* pow example */
2#include <stdio.h> /* printf */
3#include <math.h> /* pow */
4
5int main ()
6{
7 printf ("7 ^ 3 = %f\n", pow (7.0, 3.0) );
8 printf ("4.73 ^ 12 = %f\n", pow (4.73, 12.0) );
9 printf ("32.01 ^ 1.54 = %f\n", pow (32.01, 1.54) );
10 return 0;
11}