/* loop4.cpp Dave Klick CIS 150 2017-02-14 Demonstration total of user input. */ #include using namespace std; int main() { // initialize accumulator int total = 0; int num; do { // -1 is called the sentinel value since it is a special // value which signals the end of the loop cout << "Enter a number to add (-1 to quit): "; cin >> num; // do NOT add the sentinel value in to the total if (num != -1) total = total + num; } while (num != -1); cout << "The total is " << total << endl; return 0; }