C Programming
Leap Year
Learn C programming for checking given year is a leap year or not
By Geekboots
6/9/2018
0 views
leap-year.cC
#include<stdio.h>
int main() {
int year;
printf("Enter a year to check that it's a Leap year or not:\n");
scanf("%d", &year);
if(year%4 == 0) {
/* Checking for century year */
if(year%100 == 0) {
if(year%400 == 0)
printf("%d is a leap year!\n",year);
else
printf("%d is not a leap year!\n",year);
}
else
printf("%d is a leap year!\n",year);
}
else
printf("%d is not a leap year!\n",year);
return 0;
}
/* Output */
Enter a year to check that it's a Leap year or not:
2004
2004 is a leap year!
/* ------------------------------- */
Enter a year to check that it's a Leap year or not:
1900
1900 is not a leap year!
C programmingleap year