# include # include using namespace std; int main ( ) // // SUM_MINUS allows the user to enter a sequence of numbers which // are added up by the program, and the result printed. // // The user signals the end of input by giving the special input // value of -1.0. // // Input can be on a single line: 10 20 30 -1 // or on multiple lines: // 10 // 20 30 // -1 // { int n; float sum, x; cout << "Enter values, end with -1.0\n"; sum = 0.0; n = 0; cin >> x; while ( x != -1.0 ) { // // Increase the loop counter. // n = n + 1; sum = sum + x; cin >> x; } cout << "Sum of " << n << " numbers is " << sum << "\n"; return 0; }