In: Computer Science
Write a program in Cthat asks for an integer y ≥ 0, which represents a year. The program should output “YES” if the y is leap (and “NO” if it is not). A leap year is a year that has 366 days (or February 29), that is a year which is divisible by 4 but, not by 100; in exception if it is divisible by 400.
Program:
#include<stdio.h>
void main()
{
int y;
int leap = 0;
printf("\nEnter the year: ");
scanf("%d",&y);
if(y%4 == 0 && y%100 != 0)
{
leap = 1;
}
if(y%400 == 0)
{
leap = 1;
}
if(leap)
printf("\nYES\n\n");
else
printf("\nNO\n\n");
}
Screenshot: ( for reference )
Output:
Note: If you have any doubts please comment.
It will be great help If you like.