A sentinel value is a special value in the input that signals special processing or the end of input. Keep in mind that the sentinel value can not then be input as one of the regular data values.
An accumulator is a variable used to sum up values. Remember to initialize accumulators to 0 before using them.
To use an accumulator for a product (multiplication), initialize it to 1 instead of 0.
int sum = 0;
int num = 0;
while (num != -99999) { // -99999 is the sentinel value
cout << "Enter a number to be summed up: ";
cin >> num
if (num != -99999) {
sum = sum + num;
}
}
cout << "The sum is " << sum << endl;