0% found this document useful (0 votes)
45 views3 pages

Exp 3 Leap Year

Uploaded by

hole.prateek47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views3 pages

Exp 3 Leap Year

Uploaded by

hole.prateek47
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment 03

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

A year is considered a leap year if:

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:

 Years like 1996, 2000, and 2004 are leap years.


 Years like 1900 and 2100 are not leap years, while the year 2000 is a leap year.

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);

if (((year % 4 == 0) && (year % 100!= 0)) || (year % 400 == 0))


printf("%d is a leap year.", year);
else
printf("%d is not a leap year.", 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.

You might also like