C++ Program to check a Leap Year or not

C++ Program to check a Leap Year or not

In this post we will give you information about C++ Program to check a Leap Year or not. Hear we will give you detail about C++ Program to check a Leap Year or notAnd how to use it also give you demo for it if it is necessary.

In this example program, you will learn about how to check if a given year is a leap year or notin C++.

#include<iostream>using namespace std;int main() {   int year;   cout << "Enter a year in (yyyy) format: ";   cin >> year;   if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))   cout<<year<<" is a leap year";   else   cout<<year<<" is not a leap year";   return 0;}

Output:

Enter a year in (yyyy) format: 20202020 is a leap year

The logic in the above program is if a given year is divisible by 4 and 100 but not divisible by 400 it is a common year else the given year is a leap year.

Hope this code and post will helped you for implement C++ Program to check a Leap Year or not. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US