Write a C++ program that accepts a base value, x, and a power value, k. The program must use an appropriate in-built function (from the CMATH library) to obtain the result of x k . The solution must repeat the instructions, for obtaining x and k to compute and output x k , for TEN (10) times.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int k;
double x;
for (int i=0; i<10; ++i) {
cout << "Enter x: ";
cin >> x;
cout << "Enter k: ";
cin >> k;
double res = pow(x, k);
cout << x << '^' << k << " = " << res << endl << endl;
}
}
Comments