Leap year program in C Programming

  • Tech Area
  • May 12, 2024



In this tutorial, We will see how to find leap year in C programming language.

Leap year program

#include<stdio.h>
#include<conio.h>
void main()
{
int y;
clrscr();
printf("Enter year  ");
scanf("%d", &y);
if((y%4 == 0 && y%100 != 0) || (y%400 == 0))
{
printf("%d is a leap year", y);
}
else
{
printf("%d is not a leap year", y);
}
getch();
}

Output

Enter year 2300
2300 is not a leap year

The number 2300 is entered by the user is stored in the y variable. if() checked the condition if, condition is true then leap year. If condition is false then not a leap year.

if((y%4 == 0 && y%100 != 0) || (y%400 == 0))
{
printf("%d is a leap year", y);
}
else
{
printf("%d is not a leap year", y);
}


Subscribe us via Email

Join 10,000+ subscriber

Subscribe on YouTube