#include main() { int i, /* an int in the standard input */ after_i, /* the int that follows i in the standard input */ eof_flag; /* flag to signal whether EOF was encountered */ scanf( "%d", &i ); while ( ( eof_flag = scanf( "%d", &after_i ) ) != EOF ) if ( i > after_i ) /* order OK? */ break; /* if not, terminate loop */ else /* if so, update i & check next pair */ i = after_i; if ( eof_flag != EOF ) printf( "\nfile is not sorted\n" ); else printf( "\nfile is sorted\n" ); }