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 / intvar.c < prev    next >
C/C++ Source or Header  |  2005-06-16  |  1KB  |  31 lines

  1. /*                               intvar.c 
  2.  *
  3.  *   Synopsis  - Four variables of type int are declared and
  4.  *               initialized. Their values are displayed with
  5.  *               calls to printf().
  6.  *
  7.  *   Objective - Illustrates declaration of variables both with
  8.  *               and without initializers, assignment statements
  9.  *               and the use of printf() with conversion
  10.  *               specifications in its control string to print
  11.  *               the values of variables.
  12.  */
  13.  
  14. #include <stdio.h>
  15.  
  16. int main(void)
  17. {
  18.      int first;                            /* Note 1 */
  19.      int second = 2;                       /* Note 2 */
  20.      int third,
  21.      fourth = 4;                           /* Note 3 */
  22.  
  23.      first = 1;                            /* Note 4 */
  24.      third = 3;
  25.      printf("first is %d, ", first);       /* Note 5 */
  26.                                            /* Note 6 */
  27.      printf("second is %d, third is %d, and fourth is %d.\n",
  28.                                         second, third, fourth);
  29.      return 0;
  30. }
  31.