-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathleap.c
More file actions
45 lines (39 loc) · 662 Bytes
/
leap.c
File metadata and controls
45 lines (39 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// To check weather a year is leap year or not.
#include <stdio.h>
void main()
{
int year, isleap = 1;
printf("Enter year : ");
scanf("%d", &year);
if (year % 4 == 0)
{
if (year < 2000)
{
isleap = 1;
}
else if (year % 4 < 100)
{
isleap = 0;
}
if (year % 400 == 0)
{
isleap = 1;
}
else
{
isleap = 1;
}
}
else
{
isleap = 0;
}
if (isleap)
{
printf("%d is a leap year\n", year);
}
else
{
printf("%d is not a leap year\n", year);
}
}