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 / epp5.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  712b  |  37 lines

  1. /*                        epp5.c                   */
  2. /* Include Files */
  3. #include <stdio.h>
  4. /* Global Variables */
  5. int   W, X, Y, I;
  6. /* Function Prototypes */
  7. /* Add PRECONDITION and POSTCONDITION information for 
  8.  * each function
  9.  */
  10. void demonstrate( int *y, int v );
  11.  
  12. int main( void )
  13. {
  14.      W = 3;
  15.      X = 2;
  16.      Y = 1;
  17.      I = 2;
  18.  
  19.      demonstrate( &W, Y );
  20.      printf( "%d, %d, %d, %d\n", W, X, Y, I );
  21.  
  22.      demonstrate( &I, X );
  23.      printf( "%d, %d, %d, %d\n", W, X, Y, I );
  24.      return 0;
  25. }
  26.  
  27. void demonstrate( int* Y, int V )
  28. {
  29.      int   W, X;
  30.  
  31.      X  = (*Y) * V;
  32.      W  = X / 2;
  33.      *Y = W - V;
  34.      I++;
  35.      printf( "%d, %d, %d, %d\n",  V, W, X, *Y );
  36. }
  37.