Hi everyone,this program prompts a user for a leap yr code and a day code resulting in an entire year's calendar.The result displays months one below another.Can some one tell me how to make it print 2 months next to each other,that is JAN FEB then MAR APRIL below them.
#include <stdio.h>
main()
//int print_calendar(year,day_code,leap_year)
//{
{
int day_code,days_in_month,leap_year,day,month;
do
{
printf("Enter day and leap year codes:");
scanf("%d%d",&day_code,&leap_year);
}
while (day_code <0 || day_code >6);
for (month=1;month<=12;month++)
{
switch (month){/*print name and set days_in_month*/
case 1:
printf("\n\nJanuary");
days_in_month=31;
break;
case 2:
printf("\t\nFebruary");
days_in_month= leap_year ?29 :28;
break;
case 3:
printf("\n\nMarch");
days_in_month=31;
break;
case 4:
printf("\n\nApril");
days_in_month=30;
break;
case 5:
printf("\n\nMay");
days_in_month=31;
break;
case 6:
printf("\n\nJune");
days_in_month=30;
break;
case 7:
printf("\n\nJuly");
days_in_month=31;
break;
case 8:
printf("\n\nAugust");
days_in_month=31;
break;
case 9:
printf("\n\nSeptember");
days_in_month=30;
break;
case 10:
printf("\n\nOctober");
days_in_month=31;
break;
case 11:
printf("\n\nNovember");
days_in_month=30;
break;
case 12:
printf("\n\nDecember");
days_in_month=31;
break;
}
printf("\n\nSun Mon Tue Wed Thurs Fri Sat\n");
/* advance printer to correct position for first date*/
for(day =1;day <=1 +day_code*5;day++)
printf("\t");
/* print the dates for one month*/
for(day=1;day<=days_in_month;day++)
{
printf("%2d",day);
if((day+day_code)%7>0)/*before Sat ?*/
/* move to next day in same week*/
printf(" ");
else/* skip to next line to start with Sun*/
printf("");
}
/*set day_code for next month to begin*/
day_code =(day_code +days_in_month)%7;
}
}