To raise a number to a power in C++, it is enough to use the pow function, which is located in the math.h library.
The pow function takes two arguments: a number for exponentiation and an exponent of
double pow (double base, double exponent);
Sample code:
include
include
using namespace std;
int main ()
{
printf ("%g",pow(3,5));
return 0;
}
The result of this program will be the output of the number 243, which is 3 to the 5th power.
Top comments (0)