This post originated from an RSS feed registered with Java Buzz
by instanceof java.
Original Post: C program to find leap year using if else
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
A year is said to be leap year if it is divisible by 4.
For example 2004 , 2008,2012 and 2016.
A year is also a leap year if it is divisible by 100 and divisible by 400.
For example 1600 and 2000 etc.
A leap year of February moth will have 29 days.
Let us see an example C program to check a year is leap year or not using simple if condition.
First we need to check a year is divisible by 4 or not.
If yes then again one more condition if it is divisible by 100 and 400. if it is divisible by 100 then it should be divisible by 400 then only it is leap year.
c program code to find leap year using if else
Program #1: Write a C program to check a year is leap year or not without using any function.
#include <stdio.h>
#include <stdlib.h>
int main(){
int year;
printf("Enter a year to check if it is a leap year or not \n");