Answer to Question #30973 in C++ for SOLOMON
write a C++ program which will raise any number x to a positive power n using a for loop?
1
2013-06-04T08:16:14-0400
#include <iostream>
using namespace std;
int main() {
cout << "Input x: ";
double x;
cin >> x;
cout << "Input n: ";
int n;
cin >> n;
double pow = 1;
for (int i = 0; i < n; i++)
& pow *= x;
cout << pow << endl;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment