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

What\'s wrong with this program? Find the errors and fix them. // This program u

ID: 3670524 • Letter: W

Question

What's wrong with this program? Find the errors and fix them.

// This program uses a loop to raise a number to a power.

#include
using namespace std;

void main()
{
   {
       int num, bigNum, power, count;
       cout << "Enter an integer : ";
       cin >> num;
       cout << "What power do you want to raise it to ? ";
       cin >> power;
       bigNum = num;
       while (count++ < power)
           bigNum *= num;
       cout << "The result is " << bigNum << endl;

   cin.get();
   cin.ignore();

}

Explanation / Answer

using namespace std;

void main()
{
   {
       int num, bigNum, power, count=1;
       cout << "Enter an integer : ";
       cin >> num;
       cout << "What power do you want to raise it to ? ";
       cin >> power;
       bigNum = num;
       while (count++ < power)

    {  
           bigNum *= num;
           cout << "The result is " << bigNum << endl;

   }  

   Return 0;

}

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