Table of Contents

## C program for leap year

C program to check leap year :

We know that there are 365 day in a year but it is wrong. in one year there are 365.25 days. Hence every 4 year we have one extra day.

We have to use simple mathematics logic to solve this problem.

If year is divided by 4 then it is leap year.

If year is divided by 4 and not by 100 then it is leap year.

If year in not divisible by 4 then it is not a leap year.

If year is divisible by 4 and 100 then it must be divisible by 400 otherwise it is not a leap year.

int main()

{

int year;

printf("Enter year : ");

scanf("%d",&year);

if(year % 4 == 0)

{

if( year % 100 == 0)

{

if ( year % 400 == 0)

{

printf("%d is a leap year", year);

}

else

{

printf("%d is not a leap year", year);

}

}

else

{

printf("%d is a leap year", year);

}

}

else

{

printf("%d is not a leap year", year);

}

return 0;

}

Output :

Enter year : 2006

2006 is not a leap year

### PRACTICALS IN C PROGRAM

### CHECKOUT OTHER RELATED TOPICS

### CHECKOUT OTHER QUIZZES

Quizzes on Operator |

Easy Quiz on Operators in C part 1 |

Easy quiz on operators in C part 2 |

Easy quiz on operators in C part 3 |

Quizzes on Loops |

Easy quiz on loops in C part 1 |

Easy quiz on loops in C part 2 |

Easy quiz on loops in C part 3 |

Quizzes on Decision Making Statement |

Easy Quiz On Decision Making Statements Part 1 |

Easy Quiz On Decision Making Statements Part 2 |

Quizzes on String |

Easy quiz on String in C programming part 1 |

Quizzes on Array |

Easy quiz on Array in C programming – part 1 |

5 – Best Java program to convert decimal to binary |

New Quizzes Coming soon.. |

We are aiming to explain all concepts of C in easiest terms as possible.

ITVoyagers

Author