Exp 3 Leap Year
Exp 3 Leap Year
Aim : Design and develop a C program to read a year as an input and find whether it is leap
year or not. Also consider the end of the centuries. Write algorithm and draw flowchart for
the same.
Theory
1. It is divisible by 4.
2. However, if the year is a century (i.e., ends with 00), it must also be divisible by 400
to be considered a leap year.
In simpler terms:
Algorithm
1. Start.
2. Input a year.
3. Check if the year is divisible by 4.
o If not, it is a common year.
o If yes, check if the year is divisible by 100.
If not, it is a leap year.
If yes, check if it is divisible by 400.
If yes, it is a leap year.
If no, it is a common year.
4. Output whether the year is a leap year or not.
5. End.
Flow Chart :
Code :
#include <stdio.h>
int main() {
int year;
printf("Enter a valid year- ");
scanf("%d",&year);
return 0;
}
Output :
Enter a valid year- 1999
1999 is not a leap year.
Conclusion:
Determining if a year is a leap year is an important task in date and time calculations. The criteria for
identifying a leap year, particularly around century years, require careful consideration of divisibility
rules. This program effectively implements those rules in a straightforward manner, showcasing how
to use conditional statements in C. Understanding these concepts is crucial for effective programming,
especially when dealing with dates and calendars.