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;
const int REPEAT_TIMES = 2;
int main()
{
  double x, k;
  for(int i = 0; i < REPEAT_TIMES; i++)
  {
    cout << "Enter base value: ";
    cin >> x;
    cout << endl << "Enter power value: ";
    cin >> k;
    cout << endl << "Output: " << pow(x,k);
    cout << endl << endl;
  }
  cout << endl << endl;
  return 0;
}
Comments
Leave a comment