LEAP
YEAR OR NOT
Program Logic:
If the year is divisible by 4, it is a leap year.
But, if it is divisible by 100, it is not. If the year is divisible by 400, it
is a leap year.
Examples:
1. 1996 is a leap year. (divisible by 4) 3. 2100 is
a not leap year. (divisible by 100)
2. 2000 is a leap year. (divisible by 100 but also
divisible by 400)
Program:
#include <stdio.h>
#include <conio.h>
void main()
{
int year;
clrscr();
printf("Enter
a Year to check : ");
scanf("%d", &year);
if(year % 400 == 0) printf("%d is a Leap
Year.", year);
else if(year % 100 == 0) printf("%d is not a Leap
Year.", year);
else if(year % 4 == 0) printf("%d is a Leap
Year.", year);
else printf("%d is not a Leap
Year", year);
printf("\nPress any
key to Quit...");
getch();
}
No comments:
Post a Comment