WRITE A PROGRAM TO DECIDE THE YEAR IS A LEAP YEAR OR NOT?
#include<stdio.h> // Header file “Standard Input and Output”
#include<conio.h> //Header file “Console input and output”
void main ()
{
clrscr(); // Clear the output
screen
int year;
printf(“Please
enter any year ”);
scanf(“%d”,&year);
if(year%4
== 0) //
Divide the year by 4 and decide either it is leap or not
printf(“\nThis year is a leap
year”);
else
printf(“\nThis year is not a leap
year”);
getch();
}
OUTPUT
Please enter any
year 2012
This year is a
leap year
Please enter any
year 1997
This year is not
a leap year
EXPLANATION
Simple formula
is used in this program. Leap years are always fully divided by 4. So when the
user input any year, the program divided that input by 4 and if the remainder
is “0” its mean the year is leap year otherwise it is not a leap year.