Check leap year using C programming

Milan sunuwar

Milan sunuwar

· 1 min read
Thumbnail

Certainly! In C language, you can check if a year is a leap year using a simple program. A leap year is divisible by 4, but if it's divisible by 100, it should also be divisible by 400 to be considered a leap year. Here's a basic example:

#include <stdio.h>

int main() {
    int year;

    // Input the year
    printf("Enter a year: ");
    scanf("%d", &year);

    // Check if it's a leap year
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
        printf("%d is a leap year.\n", year);
    } else {
        printf("%d is not a leap year.\n", year);
    }

    return 0;
}

This program takes a user input for the year and then checks whether it's a leap year or not based on the mentioned conditions. If the conditions are met, it prints that the year is a leap year; otherwise, it prints that it's not a leap year.

Milan sunuwar

About Milan sunuwar

Computer Teacher

Copyright © 2025 Manish Tamang. All rights reserved.
Made by Manish Tamang· Github