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 the leap year. To check that the year is a leap year or not, following these rules:

C++ Programming Code to Check Leap Year or Not

Following C++ program ask to 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<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int yr;
	cout<<"Enter year :";
	cin>>yr;
	if((yr%4==0) && (yr%100!=0))
	{
		cout<<"This is a Leap Year";
	}
	else if(yr%100==0)
	{
		cout<<"This is not a Leap Year";
	}
	else if(yr%400==0)
	{
		cout<<"This is a Leap Year";
	}
	else
	{
		cout<<"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

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

leap year program c++

Same Program in Other Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test