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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.