// Here's a C++ program that calculates the power of one integer number to another:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int base, exponent;
double result;
// Input the base number
cout << "Enter the base integer: ";
cin >> base;
// Input the exponent
cout << "Enter the exponent (an integer): ";
cin >> exponent;
// Calculate the power using the pow function from the cmath library
result = pow(base, exponent);
// Display the result
cout << base << " raised to the power of " << exponent << " is: " << result << endl;
return 0;
}
No comments:
Post a Comment