c-programming

C program to find leap year or not

This is another interesting C program for beginner programmers, which is very useful for job hunters and school or college students.

Writing a C program to find leap year or not, Interesting isn’t it?

Formula for finding a Leap year is as follows:

1. Year should be evenly divisible by 4 (should not have a reminder):

year % 4 == 0 ( reminder should be 0 )

2. AND Year should not be evenly divisible by 100 (should have a reminder):

year % 100 != 0 ( reminder should not be 0 )

3. OR Year should be evenly divisible by 400 (should have a reminder):

        year%400 == 0 ( reminder should be 0 )
So basically 1 && 2 || 3

if (1  and 2) both are true or 3 is true then it is a leap year

 

Here is the C program to find the leap year,

The output of the above program will be:

C Program to check Leap year or not:
Enter a year: 2012

2012 is a leap year

 

If you feel difficult to use && / ||, you can use and / or also, like this:

 

Related Posts

Leave a Reply