C Language

May 27, 2023

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

Tags:

by : Ajaj Khan

Quick Summary:

इस program मैं leap year निकल रहा है
leap year चार वर्ष बाद आता है