C Program to Check Leap Year

In this program the user gives a number that is a leap year then the program will display the leap year. And if it is not a leap year, it will print Not, Leap Year!

We all know that there are 365 days in a calendar year. But a year takes exactly 365.2425 days. For this, after 4 years, the calendar has to be readjusted by one day. This is called a leap year.

Leap year, we will use C programming language through this program to check whether the user's given year is a leap year. Some examples of leap years are:
  • 1997 is not leap year!
  • 1996 is leap year!
  • 2024 is leap year!

    #include<stdio.h>
    int main(){
        int year;
        printf("Enter Year: ");
        scanf("%d",&year);
    
        if((year%4==0) || (year%400==0) && (year%100 !=0)){
            printf("Yes, Leap year! \n");
        }
    
        else
          printf("Not, Leap year! \n");
    
    
    return 0;
    }

    Output

    Enter Year: 1996
    Yes, Leap year!
    
  • Post a Comment

    Previous Post Next Post