Function for leap years P95401


Statement
 

pdf   zip   main.cc   main.c   main.java   main.py

thehtml

Write a function that tells if the given year is a leap year or not. To recall the rules about leap years, check the exercise ‍.

Interface

C++
bool is_leap_year(int year);
C
int is_leap_year(int year);
Java
public static boolean isLeapYear(int year);
Python
is_leap_year(year) # returns bool
 
is_leap_year(year: int) -> bool

Precondition The parameter year is between 1800 and 9999, both included.

Observation You only need to submit the required procedure; your main program will be ignored.

Public test cases
  • Input/Output

    is_leap_year(1967) → false
    is_leap_year(1968) → true
    is_leap_year(2100) → false
    is_leap_year(2400) → true
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C C++ Java Python
    User solutions
    C C++ Java Python