What’s today?

The reply could be the day of a week, such as Sunday. That’s how I first answer the question. The more detailed answer is the day of the month, which isn’t often on my mind — unless it’s an important day like a birthday or some event.

Today is Sunday, September 1st. (I didn’t need to look it up because I scheduled this post to appear on Sunday, September 1st.) But what about next Tuesday? What date will it be?

Doing the math on my fingers: Monday the 2nd, Tuesday the 3rd. Next Tuesday will be the 3rd. That was easy. But if today were September 26th, a Thursday, what will the following Tuesday be? Quick!

Don’t worry about using your fingers or remembering which months have 31 days. You can code a program in C that does all the heavy lifting for you. In fact, that’s the goal of this month’s Exercise: Write code that takes today’s date and calculates the date for next Tuesday.

Here’s a sample run:

`Today is Sunday the 1st.`

Next Tuesday will be the 3rd.

And if today is Tuesday, the program looks a week ahead:

`Today is Tuesday the 27th.`

Next Tuesday is the 3rd.

The code must recognize the end of the month — and the end of the year — then calculate the date for the following Tuesday accordingly.

Please try coding this Exercise on your own before you check out my solution.