[SOLVED] Calculating all leap years between 1600 and 300

I need help with an assignment for school;

I need to make a program that prints all leap years between 1600 and 3000, but skips the 5th one.
I also need to use modulo (%) to check the remainder.
And in the loop construction, I need to call another function called “checkLeapYear” which
takes an int (the year) as a parameter and has return type boolean.

I have never done this before and I just can’t figure it out!
Is there anyone who can explain t me what I need to do?

(deleted)

Here

(Is Google broken in the Netherlands today?)

spycatcher2k: Why do you need to do this on an Arduino?

My teacher wants us to understand how it works but I don't even know where to start...

I don't even know where to start

One place to start would be the link in reply #2.

You can start by asking the teacher which calendar to use. The idea of a leap-year is quite modern for the calendar used by various countries.

Paul

AWOL: Here

(Is Google broken in the Netherlands today?)

I know what a leap year is but i don't know how to program what i need to program

(deleted)

Think about what a leap year is , write a few down and try and work out the rules to calculate them by the relationship between them . When you’ve an equation think about how you might write code to do it .

SkullOfRianne:
I need help with an assignment for school;

I need to make a program that prints all leap years between 1600 and 3000, but skips the 5th one.
I also need to use modulo (%) to check the remainder.
And in the loop construction, I need to call another function called “checkLeapYear” which
takes an int (the year) as a parameter and has return type boolean.

I have never done this before and I just can’t figure it out!
Is there anyone who can explain t me what I need to do?

I finally found the solution

int CurrentYear = 2018; // You can change it according to the year you’re living in.
bool checkLeapYear(int the_year) {
if (the_year % 4 != 0) return false;
if (the_year % 100 == 0 && the_year %400 != 0) return false;
if (the_year % 400 == 0) return true;
return true;
}

void setup() {
Serial.begin(9600);
}

void loop() {
int counter = 1;
for(int number = 1600; number <= 3000; number++){
if(checkLeapYear(number)){
if(counter != 5){
Serial.print(number);
if(number < CurrentYear){
Serial.println(" was a leap year"); // To make clear it was in the past.
}
else Serial.println(" is going to be a leap year"); // To make clear it is in the future.
counter++;
delay(500); //Added delay so it can be read more easily.
}
else{
counter = 6;
}
}
}
}