C++ Program to Check Leap Year Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 3 Likes Like Report Try it on GfG Practice A year consisting of 366 days instead of the usual 365 days is a leap year. Every fourth year is a leap year in the Gregorian calendar system. In this article, we will learn how to write a C++ program to check leap year. A year is a leap year if one of the following conditions is satisfied: The year is a multiple of 400.The year is a multiple of 4 but not a multiple of 100.Recommended: Please solve it on “PRACTICE ” first, before moving on to the solution. Algorithm to Check Leap Year The algorithm implements the conditions specified above to check for leap year. if (year % 400 = 0) return true (Leap year) else if (year % 100 = 0) return false (Not a leap year) else if (year % 4 = 0) return true (Leap year) else return false (Not a leap year) endifLeap Year Program in C++ C++ // C++ program to check if a given // year is a leap year or not #include <iostream> using namespace std; // Function to check leap year bool checkYear(int year) { if (year % 400 == 0) { return true; } // not a leap year if divisible by 100 // but not divisible by 400 else if (year % 100 == 0) { return false; } // leap year if not divisible by 100 // but divisible by 4 else if (year % 4 == 0) { return true; } // all other years are not leap years else { return false; } } // Driver code int main() { int year = 2000; checkYear(year) ? cout << "Leap Year" : cout << "Not a Leap Year"; return 0; } OutputLeap YearComplexity AnalysisTime Complexity: Since there are only if statements in the program, its time complexity is O(1).Auxiliary Space: O(1) Create Quiz Leap Year Visit Course Comment K kartik Follow 3 Improve K kartik Follow 3 Improve Article Tags : C++ Programs C++ Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like