Basic

Switch Case

Goto

Operators

if Statement

Nested if

While Loop

For Loop

Array

Patterns

Excersises


C Program to Check Leap Year


The following example shows, how to check whether given year is Leap or Not.

Example : pgm.c

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

Output 1:

Enter Year : 1800
 1800 is not a leap year

Output 2:

Enter Year : 2000
 2000 is a leap year