From e19cc9b43029a4f89b6026eba82df013cd6eaf2f Mon Sep 17 00:00:00 2001 From: Sumanth <59635101+18EC10014@users.noreply.github.com> Date: Fri, 23 Jul 2021 15:28:30 +0530 Subject: [PATCH] Create 18EC10014_leap_ year_or _not.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We generally assume that if a year number is evenly divisible by 4 is leap year. But it is not the only case. A year is a leap year if − It is evenly divisible by 100. If it is divisible by 100, then it should also be divisible by 400. --- cpp/18EC10014_leap_ year_or _not.cpp | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cpp/18EC10014_leap_ year_or _not.cpp diff --git a/cpp/18EC10014_leap_ year_or _not.cpp b/cpp/18EC10014_leap_ year_or _not.cpp new file mode 100644 index 00000000..3e3fc57e --- /dev/null +++ b/cpp/18EC10014_leap_ year_or _not.cpp @@ -0,0 +1,30 @@ +bool isLeapYear(int n) +{ + if(n%400==0) + { + return 1; + } + else if(n%100==0) + { + return 0; + } + else if(n%4==0) + { + return 1; + } +} + +int main() +{ +int year; +cout<<"Enter the year "; +cin>>year; + if(isLeapYear(year)) + { + cout<<"The year "<