76 289
Assignments Done
Successfully Done
In May 2019

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions