Remember, computers cannot look ahead to see how things work. They only understand things one step at a time.
What is "remainder" here?
What is the range of values you can get when computing the remainder of division by 4?
What is the consequence of starting with January == 1?
There is a pattern here that has two twists:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
31 2? 31 30 31 30 31 31 30 31 30 31
↑ ↑
February is weird The pattern skips at August |
You can write a very small function that handles this weirdness very easily:
month 2 (February) is 28 + is leap year
months 1..7 are 30 days + is odd
months 8..12 are 30 days + is even
You do not need to input (cin) anything after your initial inputs for month and year.