/* Months.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-25 File created. 2013-11-25 Last modification. */ #include #include int main() { // The following is an initialized array of strings. char* names_of_months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } ; printf( "\n The first month of year is %s.", names_of_months[ 0 ] ) ; printf( "\n\n The seventh month, %s, is named after Julius Caesar.\n", names_of_months[ 6 ] ) ; printf( "\n Our calendar has %d months. \n", sizeof( names_of_months ) / sizeof( char* ) ) ; int month_index ; for ( month_index = 0 ; month_index < 4 ; month_index ++ ) { int number_of_letters_in_month_name = strlen( names_of_months[ month_index ] ) ; printf( "\n %s is made of %d letters: ", names_of_months[ month_index ], number_of_letters_in_month_name ) ; int letter_index ; for ( letter_index = 0 ; letter_index < number_of_letters_in_month_name ; letter_index ++ ) { printf( " %c", names_of_months[ month_index ] [ letter_index ] ) ; } } printf( "\n" ) ; } /* The following is the output of this program: The first month of year is January. The seventh month, July, is named after Julius Caesar. Our calendar has 12 months. January is made of 7 letters: J a n u a r y February is made of 8 letters: F e b r u a r y March is made of 5 letters: M a r c h April is made of 5 letters: A p r i l The following array could be used if you improve this program: char* history_of_months[] = { "month of Roman god Janus", // January "last month in Roman calendar", // February "month of Roman war god Mars", // March "month of Roman goddess Venus", // April "month of goddess Maia", // May "month of Roman goddess Juno", // June "month of Julius Caesar", // July "month of Emperor Augustus", // August "7th Roman month", // September "8th Roman month", // October "9th Roman month", // November "10th Roman month" } ; // December */