// This program illustrates the use of the end-of-file test function, eof(). // Notice that MAX_NUMS is a global variable. #include #include using namespace std; const unsigned short MAX_NUMS = 100; int main() { float x[MAX_NUMS]; int k = 0; cout << "Enter the numbers with a space or line break between each.\n"; cout << "Enter Crtl+Z on a line by itself when finished.\n"; cin >> x[k]; while ( !cin.eof() ) { k++; cin >> x[k]; } cout << "\nYou entered " << k << " numbers.\n"; cout << "They are:" << endl; for ( int i = 0; i < k; i++ ) { cout << x[i] << "\n"; } cout << "\n\n"; system( "PAUSE" ); return( EXIT_SUCCESS ); }