#include #include // file: stats1.cc; author: D. Ramm; date: 10/13/96 // while with EOF to exit // Initialization from limits.h // stats for undeterminded input int main() { int number, count = 0, sum = 0; int max = INT_MIN, min = INT_MAX; cout << "type in numbers; use ^D to quit" << endl; while (cin >> number) { count++; sum += number; if (number > max) max = number; if (number < min) min = number; } if (count == 0) cout << "No data entered." << endl; else cout << "For " << count << " numbers read, Max = " << max << ", Min = " << min << ", Mean = " << 1.0*sum/count << endl; return 0; } Sample output: stats1 type in numbers; use ^D to quit 23 -23 For 2 numbers read, Max = 23, Min = -23, Mean = 0 stats1 type in numbers; use ^D to quit 1 3 5 6 4 2 For 6 numbers read, Max = 6, Min = 1, Mean = 3.5 stats1 type in numbers; use ^D to quit -13 0 25 -25 1 For 5 numbers read, Max = 25, Min = -25, Mean = -2.4 stats1 type in numbers; use ^D to quit No data entered.