Question: Each of the program segments in this section has errors. Find as many as you can. // This code should use a loop to raise
Each of the program segments in this section has errors. Find as many as you can.
// This code should use a loop to raise a number to a power.
int num, bigNum, power, count;
cout << "Enter an integer: ";
cin >> num;
cout << "What power do you want it raised to? ";
cin >> power;
bigNum = num;
while (count++ < power);
bigNum *= num;
cout << "The result is << bigNum << endl;
segment 2 :
// This code should average a set of numbers.
int numCount, total;
double average;
cout << "How many numbers do you want to average? ";
cin >> numCount;
for (int count = 0; count < numCount; count++) {
int num;
cout << "Enter a number: ";
cin >> num;
total += num;
count++;
}
average = total / numCount;
cout << "The average is << average << endl;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
