codescracker


c

C Program to Check Leap Year or Not



« Previous Program Next Program »


Check Leap Year or Not in C

To check whether the input year is a leap year or not a leap year in C programming, you have to ask to the user to enter the year and start checking for leap year.

C Programming Code to Check Leap Year or Not

Following C program ask the user to enter the year to check whether it is a leap year or not, then display it on the screen:

/* C Program - Check Leap Year or Not */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int yr;
	printf("Enter year :");
	scanf("%d",&yr);
	if((yr%4==0) && (yr%100!=0))
	{
		printf("This is a Leap Year");
	}
	else if(yr%100==0)
	{
		printf("This is not a Leap Year");
	}
	else if(yr%400==0)
	{
		printf("This is a Leap Year");
	}
	else
	{
		printf("This is not a Leap Year");
	}
	getch();
}

When the above c program is compile and executed, it will produce the following result. Above C Programming Example Output (for leap year):

c program check leap year or not

Above C Programming Example Output (for not leap year):

leap year program c

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test