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

  1. /*                               incremen.c
  2.  *
  3.  *   Synopsis  - Assigns values to b using the increment and
  4.  *               decrement by 1 operators with a. Displays 
  5.  *               values of a and b.
  6.  *
  7.  *   Objective - To demonstrate the increment and decrement by
  8.  *               1 operators.
  9.  */
  10.  
  11. #include <stdio.h>
  12.  
  13. int main( void )
  14. {
  15.      int a = 3, b;
  16.  
  17.      b = a++;                                      /* Note 1 */
  18.      printf("b is %d, and a is %d.\n", b, a);
  19.  
  20.      b = ++a;                                      /* Note 2 */
  21.      printf("Now b is %d, and a is %d.\n", b, a);
  22.  
  23.      b = 5 % --a;                                  /* Note 3 */
  24.      printf("Now b is %d, and a is %d.\n", b, a);
  25.                                                    /* Note 4 */
  26.      printf("Now b is %d, and a is %d.\n", ++b, a--);
  27.      printf("Now b is %d, and a is %d.\n", b, a);
  28.      return 0;
  29. }