Home / Study Material / Java Programs

Study Materials

Check for Leap Year

Write a program to enter a number as year and check if it is a leap year or not.
A leap year satisfies two conditions-
1. If the year is a multiple of 100, then it should be divisible by 400.
2. If the year is not a multiple of 100, then it is should be divisible by 4.
Some examples of leap year are - 2000, 2004, 1992
Some examples which are not leap year - 2100, 1997

class Leap_Year
{
    public static void main(int n)
    {

        if(( n%400==0 ) || ( n%4==0 && n%100!=0 ))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}



Copyright © 2020 | All rights resereved