Prints the number of days per month. - C Array

C examples for Array:Introduction

Description

Prints the number of days per month.

Demo Code

#include <stdio.h> 

  #define MONTHS 12 //from   w w  w  .jav a2  s .  c om
   
  int main(void) 
  { 
      int days[MONTHS] = {31,28,31,30,31,30,31,31,30,31,30,31}; 
      int index; 
   
      for (index = 0; index < MONTHS; index++) 
          printf("Month %d has %2d days.\n", index +1, 
                 days[index]); 
   
      return 0; 
  }

Result


Related Tutorials