# include # include using namespace std; int main ( ) // // SUM_EOF 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 with the EOF character CTRL-D. // { int n; float sum, x; cout << "Enter values, end with CTRL-D\n"; sum = 0.0; n = 0; cin >> x; while ( !cin.eof ( ) ) { // // Increase the loop counter. // n = n + 1; sum = sum + x; cin >> x; } cout << "Sum of " << n << " numbers is " << sum << "\n"; return 0; }