Question: const int SENTINEL = -1; int count = 0; int sum = 0; int num; double average; cout < < Enter a value: (or -1

const int SENTINEL = -1; int count = 0; int sum = 0; int num; double average;

cout << "Enter a value: (or -1 to quit): " << endl; cin >> num; while (num != SENTINEL) { cout << "Enter a value: (or -1 to quit): " << endl; cin >> num; count++; sum += num; }

average = sum/count;

The code above is part of a working program and has a logic error. Describe it, and indicate how to fix it.

(Remember that only partial code is shown here. The answer is not that this is an incomplete program and that a main function is needed.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!