Leap year program in C

Leap year program in C

Leap year program in C

First of all, it is important to know what is leap year? Generally, a year has 365 days in a year, but a leap year has 366 days which comes after four year. Below are some points related to leap year:

  • A leap year is a year, which is different than a normal year having 366 days instead of 365.
  • A leap year comes once in four years, in which February month has 29 days. With this additional day in February, a year becomes a Leap year.
  • Some leap years examples are – 1600, 1988, 1992, 1996, and 2000.
  • Although 1700, 1800, and 1900 are century years, not leap years.

Below conditions are used to check that year is a leap year or not.

  1. Year must be divisible by 4
  2. Year is divisible by 400 and not divisible by 100.

By putting these conditions in your code, you can check year is a leap year or not. If the above conditions are satisfied, the year will be leap year. These conditions can be put with if-else or with && (and) and || (Or).

How to find leap year using C programming?

With the help of a C program, we will make easy to find a leap year.


See the below example in which we check a leap year by taking input from user:



void main() {

int year;

printf(“Enter a year: “);

scanf(“%d”, &year);

if(((year%4==0) && ((year%400==0) || (year%100!==0))


printf(“%d is a leap year”, &year);

else {

printf(“%d is not a leap year”, &year);





See the below outputs for different input values:

Test 1:

Enter a year: 2004
2004 is a leap year


Related Post:

Features of C Programming Language

Variables in C

Data Types in C

Keywords in C

C Operators

Comments in C

Escape Sequence in C

C Functions

Storage Classes in C

Dynamic memory allocation in C

Factorial Program in C

Fibonacci Series in C

Prime Number program in C

Palindrome program in C

Sum of digits program in C

Escape Sequence in C

ASCII value in C

Difference Between Type Casting and Type Conversion in C

Difference Between Variables and Constants

Matrix multiplication in C

C Program to generate Fibonacci Triangle

C Program to print “hello” without semicolon

C Program to swap two numbers without third variable

C Program to reverse number

Count the number of digits in C

Tokens in C

C Identifiers

C Strings

Compile time vs Runtime in C

C break statement

C goto statement

Type Casting in C

C String Functions

C Pointers

Dangling Pointers in C

void pointer in C

Pointer to Pointer in C

Recursion in C

Call by value and Call by reference in C

File Handling in C

C fprintf() and fscanf()

C fputc() and fgetc()

C fputs() and fgets()

C fseek() function

Constant Pointers in C

2 thoughts on “Leap year program in C

  1. Pingback: Escape Sequence in C - CloudNClear

  2. Pingback: ASCII value in C - CloudNClear

Comments are closed.