C Tutorial
This c program is used to find the month in word from month in number and months defined using two dimentsional array.
Returns month in word if user enters number of month in year.
#includevoid main() { int number_of_month; char months[12][15] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; printf("\nEnter number of month in year [1-12]:"); scanf("%d", &number_of_month); printf("\nMonth in year: %s", months[number_of_month-1]); }
Output:
$ cc month_in_year.c $ ./a.out Enter number of day in week [1-7]:11 Week day: November $ ./a.out Enter number of month in year [1-12]:9 Month in year: September
This c program is used to find the month in word from number of month and months defined using array of pointers.
Returns month in word if user enters number of month in year.
#includevoid main() { int number_of_month; char *months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; printf("\nEnter number of month in year [1-12]:"); scanf("%d", &number_of_month); printf("\nMonth in year: %s", months[number_of_month-1]); }
Output:
$ cc month_in_year.c $ ./a.out Enter number of month in year [1-12]:3 Month in year: March $ ./a.out Enter number of month in year [1-12]:9 Month in year: September
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page