home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch2 / epp7.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  760b  |  32 lines

  1. /*              epp7.c               */
  2.     
  3. /* Include Files */
  4. #include <stdio.h>
  5.  
  6. /* Function Prototypes */
  7. int positive( int num );
  8. /*   PRECONDITION:  num is any integer.
  9.  *
  10.  *   POSTCONDITION: The return value is 1 if num > 0
  11.  *                  and 0 otherwise.
  12.  */
  13.  
  14. int main( void )
  15. {
  16.      int inputint;
  17.  
  18.      printf( "Enter an integer and " );
  19.      printf( "press return after the prompt.\n" );
  20.      printf( "Signal EOF when you are done.\n" );
  21.      printf( ">>> " );
  22.  
  23.      while ( scanf( "%d", &inputint ) != EOF ) {
  24.           if ( positive( inputint ) )
  25.                printf( "That one was positive.\n" );
  26.           else
  27.                printf( "That one wasn't.\n" );
  28.           printf( ">>> " );
  29.      }
  30.      return 0;
  31. }
  32.