C program to find leap year:
What is leap year?
Leap year is a year which has 366 days. Leap year occurs once every 4 years.
How to find whether a year is leap year or not using a C program?
* A year which can be exactly divisable by 4 except century years is called leap year.
* Century year means the year which ends with 00. Century year also can be a leap year if it is exactly divisable by 400.
C program to find whether a given year is leap year or not:
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 |
#include <stdio.h> int main() { int year; printf("\nPlease enter a year to check whether it is a leap year or not"); scanf("%d", &year); if ( year%400 == 0) printf("\n%d is a leap year", year); else if ( year%100 == 0) printf("\n%d is not a leap year", year); else if ( year%4 == 0 ) printf("\n%d is a leap year", year); else printf("\n%d is not a leap year", year); return 0; } |