### calendar algrothim

hey, i was suppose that (day)1/(month)1/(year)1 it was satrday,and counter =0;

for(int i=1;i<year;i++){
if year is leap conter+=2;
else counter++;
}
counter %= 7;

and after that the counter will represent the days of weak from (0 -> 6)
there is cases goes right but there is wrong too is my thinking is wrong ??
Last edited on
I'm not too sure what you're asking.

You gave this:
 ``123456789`` ``````for(int i=1; i

In this case, you may want to take
 ``12`` ``````int check = year%4 if(check == 0)///if check is 0, indicates leap year ``````

to find out if its a leap year or not. But seriously, I don't understand the rest of the question.

Assuming these conditions:
year = 2004

when you pass year through the FOR loop, in the end:
counter = 4008

And if I know my code right
`counter %=7;`
makes
 `counter = 4`

So if you wanted 4 to represent days of the week, then you're good.
What is the calendar algorithm
1(str),2(sun),3(mon) and so on. that's what i mean, it's work on some cases but wrong on the other i don't know why that give me wrong answer ?!
what greenleaf800073 said, you should post the algorithm
Topic archived. No new replies allowed.