C Program for Leap Year Calculation

C Program to check/to Determine Leap year or not


The below c program will check whether the given year is leap year or not. It will help us to determine the given year is leap year or not. Just enter the years in years array. Here the function is_leap_year is used to check the given year is leap year or not.

Test for leap year

#include <stdio.h>

int is_leap_year(int year);
int main(void) {
int years[4] = {2000, 2004, 2008, 2012};
int i = 0;

for(i = 0; i < 4; i++) {
if(is_leap_year(years[i]) == 1)
printf("%d is a leap year
", years[i]);
else
printf("%d is not a leap year
", years[i]);
}

return 0;
}
int is_leap_year(int year) {
if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
return 1; /* leap */
else
return 0; /* no leap */
}


Related Topic Check Leap Year in Java
Basic Linux Commands
PHP Date and Time Function Formatting Options
PHP checkdate function to Check the Given Date
Java to Calculate Standard Deviation
C  maths  

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback