So I am doing a calculating date to day of the week assignment for my class and one part of it has me all stubbed up. In the "procedure" for calculating the day of the week, part of it takes the last two digits of the year that was inputted and I can't figure out how to get those last two digits unless I have the user literally input them. This is the formula I'm trying to work with:
1 2 3 4 5 6 7
int total;
total = (
(centuryYear) +
(year%2) +
(year%2 / 4)+
(monthTable) +
(day) );
The %2 was my latest messing around from reading a couple of other posts here but it is the (year) that I only need the last two digits of; like 1961 I just need the 61 and then the 61/4.
Might I add thank you so very much. It works like a dream now (after I fixed my leap year issue). I am just curious about the 'why' now because I can't find much about it in this context. I mean there's tons about it for remainders but there's no decimal place here.
Remember in 1st and 2nd grade when they taught you to divide with remainders? That is what the % operator, known as "modulo", is doing. It divides the integer on the left by the integer on the right and returns the remainder.
Examples:
10 % 5 = 0 (5 goes into 10 two times, with nothing left over)
10 % 4 = 2 (4 goes into 10 two times, with 2 left over)
10 % 3 = 1 (3 goes into 10 three times, with 1 left over)
10 % 2 = 0 (2 goes into 10 five times, with nothing left over)