C Program to check whether a year is a leap year

The following is a C program which checks whether the entered year is a leap year or not.

Expected Output:

1st run:

2nd run:

How it works

To determine whether a year is a leap year or not, we use the following algorithm:

  1. Check if the year is divisible by 4. If it is, go to step 2, otherwise, go to step 3.
  2. Check if the year is divisible by 100. If it is, go to step 3, otherwise, the year is a leap year
  3. Check if the year is divisible by 400. If it is, then the year is a leap year, otherwise, the year is not a leap year.
%d bloggers like this: