C++ Program to Check Leap Year

Submitted by:J Kamy81

Date added:12 June, 2018

Category:C++

This program checks whether an year (integer) entered by the user is a leap year or not.

Tags: check leap year

Code Snippet:

#include <iostream>
using namespace std;

int main()
{
int year;

cout << "Enter a year: ";
cin >> year;

if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
cout << year << " is a leap year.";
else
cout << year << " is not a leap year.";
}
else
cout << year << " is a leap year.";
}
else
cout << year << " is not a leap year.";

return 0;
}
 
 

Comments