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

  1. /*                   register.c
  2.  *
  3.  *   Synopsis  - Displays two integer values.
  4.  *
  5.  *   Objective - Illustrates register variables.
  6.  */
  7.  
  8. /* Include Files */
  9. #include <stdio.h>
  10.  
  11. /* Function Prototypes */
  12. int increment_a_lot( void );
  13. /* PRECONDITION:  none.
  14.  *
  15.  * POSTCONDITION: Increments a register local variable 1000 times and
  16.  *                returns the incremented value.
  17.  *
  18.  */
  19.  
  20. int main( void )
  21. {
  22.      printf( "%d\n", increment_a_lot() );
  23.      printf( "%d\n", increment_a_lot() );
  24.      return 0;
  25. }
  26.  
  27. /*******************************increment_a_lot()*****************/
  28.  
  29. int increment_a_lot( void )
  30. {
  31.      register int number = 0;                          /* Note 1 */
  32.  
  33.      for ( ; number < 1000; number++ )                 /* Note 2 */
  34.      ;
  35.      return ( number );
  36. }