C program to check a leap year.

 

01 #include <stdio.h>
02
03 int main()
04 {
05 int year;
06
07 printf("Enter a year to check if it is a leap yearn");
08 scanf("%d", &year);
09
10 if ( year%400 == 0)
11 printf("%d is a leap year.n", year);
12 else if ( year%100 == 0)
13 printf("%d is not a leap year.n", year);
14 else if ( year%4 == 0 )
15 printf("%d is a leap year.n", year);
16 else
17 printf("%d is not a leap year.n", year);
18
19 return 0;
20 }
 
OUTPUT :

(1st Run)

Enter a year to check if it is a leap year
2004
2004 is a leap year.

(2nd Run)

Enter a year to check if it is a leap year
2006
2006 is not a leap year.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.