#does this function work to find the correct number of days from leap years?

3 messages · Page 1 of 1 (latest)

oak fiber
#

`void leapYear(int uYear, int* leap){
int ab = uYear - 1;
int at = 0;
int* an = leap;
for(; ab > 0; ab--) {
if (ab % 4 == 0){
at++;
} if (ab % 100 == 0 && ab % 400 != 0){
at--;
}
}

*an = at;

}
`
I've tested it for the current date and it seems correct.

compact quest
#

Looks correct, you could probably eliminate the loop entirely, could just return the value instead of using an out pointer too but whatever

#

logic itself seems fine