leapYear(year)

beingchinmay

New member
This function returns true if the current year is a leap year; otherwise, it returns false. The basic rule used for the decision is that a leap year occurs every four years, in the same year of the summer Olympic games. More exactly, if the year is divisible by 4, it is a leap year. Therefore, the modulo operator suits the case perfectly. If year % 4 is zero, the year is divisible by 4, meaning the current year is a leap year. Otherwise, the year is not divisible
by 4, so false is returned. An obvious call to this function is:
 
Back
Top