C program to check leap year

devquora
devquora

Posted On: Dec 23, 2020

C program to check leap year

 

Overview:

Leap years has an extra, or intercalary, day which is added to the end of the shortest month, February. The February 29, is commonly referred to as leap day or intercalary day. This article Shows communicate the definition of year, leap year, and century year. Furthermore, I will demonstrate and write logic for checking leap year. After all, I will show a C program to check leap year.

Table of contents:

  1. What is a Year?
  2. What do you mean by Leap year?
  3. What do you mean by century Leap year?
  4. Identification of Leap Years
  5. How to find the Leap Years?
  6. C program to check leap year
  7. Conclusion

What is a Year?

The time taken by the earth to make one revolution around the sun. It is the period of 365 days (or 366 days in leap years) a new year generally starting from the first of January and ending with 31st of December. It is used for reckoning time in ordinary circumstances. For instance, The time period from 1 April 2020 to 31 March 2021 is accpted as 1 Year that has 365 days but the time period from 1 January 2000 to 31 December 2000 is accpted as 1 Year that has 366 days and also it is a leap year because fabrury, 2000 has 29 days.

What do you mean by Leap year?

Leap years has an extra, or intercalary, day which is added to the end of the shortest month, February. The February 29, is commonly referred to as leap day or intercalary day. Leap years have 366 days instead of the usual 365 days and occur almost every four years. For instance, If the year 1996 is a leap year then next leap year will be year 2000. Other examples, 1999 is not a leap year 2000 is a leap year 2004 is a leap year

What do you mean by century Leap year?

A century leap year is a leap year in the Gregorian calendar that is divisible by 400. For example, the years 1600, 2000, and 2400 are century leap years since those numbers are divisible by 400, while 1700, 1800, 1900, 2100, 2200, and 2300 are common leap years despite being divisible by 4 but 1997 is not a leap year because it is not divisible by 4.

Identification of Leap Years

Demo of leap year

How to find the Leap Years?

  • Step 1: Take a variable and store a year into it as integer.
  • Step 2: If year is exactly divisible by 4.
  • Step 3: Then the year is leap year.
  • Step 4: Else year is not divisible by 4, year is normal year.

C program to check leap year

#include 
int main() {
   int year;
   printf("Enter a year: ");
   scanf("%d", &year);
   if (year % 4 == 0) {
      printf("%d is a leap year.", year);
   }
   else {
      printf("%d is not a leap year.", year);
   }
   return 0;
}

The output of the Program:

Leap demo

Conclusion:

This Program accepts year from users and check whether the given year is leap year or not using ladder if else.

    Please Login or Register to leave a response.

    Related Articles

    C Program Examples

    C Program to convert Decimal to Binary Number

    A Decimal Number is constructed with any digit from 0 to 9. For instance, 24 is a Decimal Number constructed from the digits 2 and 4. A Binary Number is constructed with digits 0 and 1. For instance, ..

    C Program Examples

    C program to reverse a string

    This program reversed the entered string that means opposite of the previous string sequence...

    C Program Examples

    C program to reverse an Integer number

    Are you want a demonstration of The C Program that reverses an Integer number? This Program reversing the sequence of digits in an Integer. After the successful compilation of the program, a message..