Here is source code of the C++ program which checks if the year entered is a leap year. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.
* C++ Program to Check if the Entered Year is a Leap Year
using namespace std;
cout << "Enter the year in yyyy format : ";
cin >> year;
if (year % 4 == 0)
cout << year << " is a leap year";
cout << year << " is not a leap year";
$ g++ main.cpp $ ./a.out Enter the year in yyyy format : 2013 2013 is not a leap year $ ./a.out Enter the year in yyyy format : 2012 2012 is a leap year
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
If you liked this C++ Program, kindly share, recommend or like below!