home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / ctutor2.zip / STRUCT1.C < prev    next >
Text File  |  1989-11-10  |  793b  |  36 lines

  1.                                          /* Chapter 11 - Program 1 */
  2. #include "stdio.h"
  3.  
  4. void main()
  5. {
  6.  
  7. struct {
  8.    char initial;    /* last name initial      */
  9.    int age;         /* childs age             */
  10.    int grade;       /* childs grade in school */
  11.    } boy,girl;
  12.  
  13.    boy.initial = 'R';
  14.    boy.age = 15;
  15.    boy.grade = 75;
  16.  
  17.    girl.age = boy.age - 1;  /* she is one year younger */
  18.    girl.grade = 82;
  19.    girl.initial = 'H';
  20.  
  21.    printf("%c is %d years old and got a grade of %d\n",
  22.            girl.initial, girl.age, girl.grade);
  23.  
  24.    printf("%c is %d years old and got a grade of %d\n",
  25.            boy.initial, boy.age, boy.grade);
  26. }
  27.  
  28.  
  29.  
  30. /* Result of execution
  31.  
  32. H is 14 years old and got a grade of 82
  33. R is 15 years old and got a grade of 75
  34.  
  35. */
  36.