Skip to content

Commit eaf7618

Browse files
committed
leap year
1 parent f927620 commit eaf7618

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

prog.6.5.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Program to determine if a year is a leap year
2+
3+
#include <stdio.h>
4+
5+
int main (void)
6+
{
7+
int year, rem_4, rem_100, rem_400;
8+
9+
printf ("Enter the year to be tested: ");
10+
scanf ("%i", &year);
11+
12+
rem_4 = year % 4;
13+
rem_100 = year % 100;
14+
rem_400 = year % 400;
15+
16+
if ( (rem_4 == 0 && rem_100 != 0) || rem_400 == 0 )
17+
printf ("It's a leap year.\n");
18+
else
19+
printf ("Nope, it's not a leap year.\n");
20+
21+
return 0;
22+
}

0 commit comments

Comments
 (0)