C Program to Check for Leap Year/Leap Year Generation

This is the C program to check whether a given year is leap year or not.the second program generates leap year within the limit specified

[cc lang=”c”]
#include
main()
{
int year;
printf(“Enter a year n”);
scanf(“%d”,&year);
if(year%400==0||year%4==0)
printf(“LEAP YEAR n”);
else
printf(“NOT A LEAP YEAR n”);
}
[/cc]

Leap Year Generation:

[cc lang=”c”]
#include
main()
{
int i;
for(i=1990;i<=3000;i++) if(i%400==0||i%4==0) printf("%dn",i); } [/cc]

You may also like...

Leave a Reply

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