// ave.cpp: compute average of integers read from standard input // Reads integers until end-of-file; no prompt for input. #include using namespace std; int main() { int sum = 0, count = 0; int number; cin >> number; while ( cin ) { int new_sum = sum + number; sum = new_sum; ++count; cin >> number; } if ( count == 0 ) cout << "No average for an empty input." << endl; else cout << "Average: " << float(sum) / float(count) << endl; return 0; }