// Oldham, Jeffrey D. // 1999 Sep 09 // CS1320 // Typed by Justin Bronn for CS1320-5. // This program sums and averages the integers in a file or typed by // the user. #include int main() { int x; int count=0; int sum=0; cout << "Enter an integer (or Ctrl+D if no more integers): "; while (cin >> x) { count = count+1; sum = sum+x; cout << "Enter an integer: "; } double decimalsum=sum; cout << "The sum is: " << sum << ".\n"; if (count==0) cout << "The average is not defined. \n"; else cout << "The average is: " << decimalsum/count << ".\n"; return 0; }