224k views
1 vote
define an array of 12 structures of type DayMon. Name the array maps[] and initialize the array with the names of the 12 months in a year and the number of days in each month.

1 Answer

2 votes

Answer:

#include<stdio.h>

int main(){

int i,n;

char* maps[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

for(i=0;i<12;i++){

printf("%s\\", maps[i]);

}

printf("\\");

int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};

for(i=0;i<12;i++){

printf("%s %d\\", maps[i], days[i]);

}

printf("\\");

return 0;

}

Step-by-step explanation:

The C source code above declares two arrays, the maps array which is initialized with the months of the year and the days array which is initialized with the number of days of each month in the maps array. Both arrays are printed out side by side like a table of months and the days in each month.

User Mukesh Methaniya
by
4.9k points