To design a small program that determines whether a given year is a leap year, we must first clarify the definition and calculation method of a leap year.
First, a leap year has 366 days, while a common year has 365 days.
Next, we need to determine the calculation method for leap years, which has been taught in elementary school; even if you don’t know it, you can look it up.
The rules for determining leap years in the Gregorian calendar are as follows:
If the year is not a multiple of 100 and is divisible by 4, then it is a leap year;
If the year is a multiple of 100 (i.e., a century year) and is divisible by 400, then it is a leap year.
The Gregorian calendar was promulgated by Pope Gregory XIII in 1582 and was gradually accepted by various countries, eventually replacing the Julian calendar to become the most widely used calendar in the world today.

In 46 BC, the Roman consul Julius Caesar promulgated the Julian calendar, which was used until 1582, lasting for 1536 years. The Julian calendar is still used by some specific groups or religious institutions today.
The method for determining leap years in the Julian calendar is very simple: If the year is divisible by 4, then it is a leap year.
With these calculation methods established, the next task is to express them in C language, which means translating the thought process into a program algorithm.
The core algorithms are as follows:
Leap year in the Gregorian calendar: (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
Leap year in the Julian calendar: (year % 4 == 0)
After clarifying the thought process and algorithms, we can design a small program to determine leap years using the syntax and format of C language.
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdbool.h>#include <stdlib.h>// Determine if it is a leap year in the Julian calendarbool isJulianLeap(int year) { return year % 4 == 0;}// Determine if it is a leap year in the Gregorian calendarbool isGregorianLeap(int year) { return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);}// Clear input buffervoid clearInputBuffer() { int c; while ((c = getchar()) != '\n' && c != EOF);}int main(){ while (1) { int year; printf("Please enter a year:"); scanf("%d", &year); clearInputBuffer(); // Clear residual input like newline printf("\n"); // Empty line // Gregorian calendar judgment (display first) if (isGregorianLeap(year)) { printf("Gregorian calendar: %d is a leap year, with 366 days\n", year); } else { printf("Gregorian calendar: %d is a common year, with 365 days\n", year); } printf("\n"); // Empty line // Julian calendar judgment if (isJulianLeap(year)) { printf("Julian calendar: %d is a leap year, with 366 days\n", year); } else { printf("Julian calendar: %d is a common year, with 365 days\n", year); } printf("\nPress Enter to continue..."); getchar(); // Wait for user to press Enter system("cls"); // Clear screen for Windows } return 0; // Keep return, standard writing}
The results show::





In all complete century intervals (100 years), the leap years determined by both the Gregorian and Julian calendars have at least 24 that are the same.
The difference between the two is that the Julian calendar has a fixed 25 leap years per century, while the Gregorian calendar may not have a leap year in a certain century year (e.g., 1900, 2100), resulting in only 24 leap years in that century.