# C++ calendar HELP!!!

• 11-13-2004
chocha7
C++ calendar HELP!!!
HI i just started learning C++ in the past month. I need help on writing a functino to calculate the first day of the month from the input year. I have no idea where to start, this counter-controlled loop is killin me, it says write a counter-controlled loop whose counter represents eacy year between 1900 and the input year - 1. could somebody show me a function to help me out please!!
• 11-13-2004
Salem
Code:

```for ( y = 1900 ; y < inputyear ; y++ ) {     // do something }```
Without leap years, the first day of January each year advances by one day.
So 1/1/1900 was Monday, so 1/1/1901 was Tuesday.
And so on until you've counted how many years you want to.
• 11-13-2004
chocha7
C++ calendar
So if i did:
int calcDay(int month, int year)
{
int day=1;
for(y=1900;y< year; y++)
{
if (isLeap(year))
day = day + 366;
else
day = day = 365;
day = day % 7;
}
}

it should calculate the day from the input year right??
• 11-13-2004
Salem
Yeah, something like that
• 11-13-2004
chocha7
ok so now that i got that...how bout the function to output the body of a calendar. something like?
• 11-13-2004
Salem
> how bout the function to output the body of a calendar
30 days hath september...
Just more loops, and knowing how many days there are in each month
• 11-14-2004
misplaced
while we're on the subject, i was wondering what more advanced programmers would think of this function
Code:

```int daysInMonth(int year, int month) {     Date temp(year, month, 1);     switch(month)     {         case 2:             if(temp.isLeap())                 return 29;             else                 return 28;         case 4:         case 6:         case 9:         case 11:             return 30;         default:             return 31;                     }          return 0; }```
• 11-14-2004
novacain
if it has to work for any year....

To correct the calendar in 1582 10 days were arbitrarily omitted, 1582 October 4th being followed by 1582 October 15th.