The Problem:
If 01/01/1900 is monday...then find the day on every Jan 1st of the year entered through the keyboard.
I have been thinking quite a lot about this program..trying to search around with some logic...but no!
My level is too low to understand arrays, functions..etc.
I've just done a couple of chapters..if-else and stuff..and I am given this program.
Trying to figure out what is the logic like to find out what is the day after 365 days..
Still thinking..but no luck so far..
Finally decided to post and get some help.
I finally found this link which helped me develop some ideas as to how the program is to be done:
http://quasar.as.utexas.edu/BillInfo/doomsday.html
I figured out that the closest Doomsday to the required Date is Jan 31 - 1/31 (2/0).
For 19xx, the Doomsday is Wednesday.
Now to calculate the doomsday for that particular year, the following procedure is to be followed
xx as in 19xx
The xx can be found out by
19xx%100
Q=xx/12
R=xx%12
S=R/4
Doomsday=Q+R+S
Now, we have to count Q+R+S number of days ahead of Wednesday. If this Doomsday calculation results in a number less than 7, then there won't be a problem.
But if it is a number greater than 7, then how can i write the code so that the addition starts again from 1?
Like 3+7 should be 3!
I hope I am going in the right direction!
Also, just thought about the Leap Year thing.
There has to be two conditions.
If it is a leap year, then doomsday falls on 2/1 (2-Feb...1-1st Day)
If it is not, then it falls on 1/31.
I suppose I will have to use an if-else to sort out the two conditions.