1
0

day_mon3.c 356 B

123456789101112131415
  1. /* day_mon3.c -- uses pointer notation */
  2. #include <stdio.h>
  3. #define MONTHS 12
  4. int main(void)
  5. {
  6. int days[MONTHS] = {31,28,31,30,31,30,31,31,30,31,30,31};
  7. int index;
  8. for (index = 0; index < MONTHS; index++)
  9. printf("Month %2d has %d days.\n", index +1,
  10. *(days + index)); // same as days[index]
  11. return 0;
  12. }