/* Reads a list of 0 or more non-negative integers flagged by a negative. Outputs the count, sum, and average of the list. */ /* NOTE! The program is down a couple of pages...don't scroll down until you've run the program and attempted to guess at the error */ #include int main() { int num, count, sum; float average; cout << "In these labloop programs, enter a negative number to stop" << endl; cout << "Begin LabLoop1 ..." << endl << endl; cout << "Enter the next number> "; cin >> num; while (num >= 0) { sum = 0; count = 0; sum = sum + num; count++; cout << "Enter the next number> "; cin >> num; } cout << endl; if (count == 0) cout << " the list is empty" << endl; else { average = float(sum)/float(count); // we need to cast at least one to real cout << " Size of list: " << count << endl << " Sum of list: " << sum << endl << "Average of list: " << average << endl; } cout << endl << "End LabLoop1" << endl; return(0); }