67 060
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #30973 in C++ for SOLOMON

Question #30973
write a C++ program which will raise any number x to a positive power n using a for loop?
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions