C program to find out whether a given year is a leap year or not

#include<stdio.h>
#include<conio.h>

void main()
{
int year;
clrscr(); //to clear the screen

printf(“Enter any year(4-digit):”);
scanf(“%d”,&year);

if(year%100==0)
{
  if(year%400==0)
     printf(“Leap Year”);
}
else
  if(year%4==0)
printf(“nLeep Year”);
else
printf(“nNot leap year”);
getch(); //to stop the screen
}

6 thoughts on “C program to find out whether a given year is a leap year or not

    1. Parikshith Rai

      the logic is
      1) the year should be divisible by 400 and 100 ,that is; only 400 because the no divisible by 400 will also be divisible by 100
      or
      2) the no should be divisible by 4 and not divisible by 100.
      so it should be
      if(year%400==0||year%4==0&&year%100!=0);

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *