Leap Year In JavaScript

Leap Year


let year = 2100;
// Define variable year and initialize value
{
  if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
    // three conditions to find leap year
    // The number which is divided by 4 or 400 is a leap year.
    // The number that divided by 100 is not zero is leap year

    console.log(year + " is leap year");
  } else {
    console.log(year + " is not leap year");
  }
}

Output


2100 is not leap year

How to use leap year in c language

program to use leap year in c language


#include <stdio.h>
int main()
{
    int year;
    printf("enter year : ");
    scanf("%d", &year);
    if (year % 100 != 0)
    {
       
        if (year % 4 == 0)
        {
            printf("leap year\n");
        }
        else
        { 
            printf("not leap\n");
        }
    }
    else
    {
        if (year % 400 == 0){
            printf("leap year\n");
        }
        else
            printf("not leap\n");
    }
    return 0;
}

output


enter year : 2028
leap year