int get_1st_weekDay(int year){//17 int day; day = (((year - 1) * 365) + ((year - 1) / 4) - ((year - 1) / 100) + ((year) / 400) + 1) % 7; return day; } int main() { system("Color FC"); //1 int year;//3 int month;//6 int day;//10 int daysInMonth;//12 int weekDay=0;//14 int startingDay;//16 printf("\nEnter your desired year : ");//2 scanf(" %d", &year); //4 char *months[]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "november" , "December"}; //5 int monthDay[]={31,28,31,30,31,30,31,31,31,30,31,30};//8 if((year%4==0 && year%100!=0)||(year%400==0))//9 monthDay[1]=29; startingDay=get_1st_weekDay(year); for(month=0; month<12; month++){//7 daysInMonth=monthDay[month];//13 printf("\n\n-------------------------%s-----------------------------\n", months[month]); printf("\n Sun Mon Tue Wed Thu Fri Sat \n"); for(weekDay=0;weekDay<startingDay;weekDay++) //19 printf(" "); for(day=1; day<=daysInMonth; day++){//11 printf("%5d", day); if(++weekDay>6){//15 printf("\n"); weekDay=0; } startingDay=weekDay;//18 } } return 0; }