Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Programming Using Microsoft Visual Studio 2017 I need the compiler to be usi

ID: 3869909 • Letter: C

Question

C++ Programming Using Microsoft Visual Studio 2017

I need the compiler to be using the programming style of Visual Studio. Thank you!

Write a program that will ask the user for two integer numbers.

Use a “for” loop to raise the first number to the power of the second number.

I recommend using the long type instead of int type.

Display the answer to the screen.

Example session (your messages may be different if you wish):

ITSE 1307 lab #4, John Q. Public

Enter a number: 5

Enter the power to raise

5 to: 3 5 to the 3 power is 125

Add a “while” loop or “do while” loop around your existing code:

Once the answer has been displayed, ask the user if they want to calculate another. Validate the user's response to be Y or N or y or n.

Example session:

ITSE 1307 lab #4, John Q. Public

Enter a number: 10

Enter the power to raise 10 to: 5

Working:

10 to the 5 power is 100000

Do you want to raise another number to a power? a

Please enter Y or N

Do you want to raise another number to a power? n

Goodbye, program is terminating.

Explanation / Answer

#include <iostream>
using namespace std;

int main () {// start program
char ch = 'Y';
cout<<"ITSE 1307 lab #4, John Q. Public"<<endl;
int n,p,result=1;
while(ch =='Y') {
  
result = 1;
cout<<"Enter a number: ";
cin >> n;
cout<<"Enter the power to raise: ";
cin >> p;
cout<<"Working: "<<endl;
for(int i=0;i<p;i++){
result = result * n;
}
cout<<n<<" to the 5 power is "<<result<<endl;
cout<<"Do you want to raise another number to a power? "<<endl;
cin >> ch;
while(ch != 'Y' && ch != 'N'){
cout<<"Please enter Y or N"<<endl;
cout<<"Do you want to raise another number to a power? "<<endl;
cin >> ch;
}
}
return 0;
} // end of program

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote