Q:

C++ program to check leap year

0

C++ program to check leap year

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to check Leap year or not in C++

#include <iostream>
using namespace std;

int main()
{
	int year;
	
	//read year
	cout<<"Enter a year: ";
	cin>>year;
	
	if((year%400==0)||(year%4==0 && year%100!=0))
		cout<<year<<" is Leap year"<<endl;
	else
		cout<<year<<" is not Leap year"<<endl;
	
	return 0;
}

Output

First run:
Enter a year: 2000
2000 is Leap year 

Second run:
Enter a year: 2005
2005 is not Leap year 

Third run:
Enter a year: 1900
1900 is not Leap year 

Fourth run:
Enter a year: 1904
1904 is Leap year 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Most popular and Searched C++ solved programs with Explanation and Output

Similar questions


need a help?


find thousands of online teachers now
C++ program to convert lowercase character to uppe... >>
<< C++ Program to check if a number is even using Rec...