# Check leap year

Here given code implementation process.

``````// C Program to
// Check leap year
#include <stdio.h>

//Function which is check whether given year is leap year or not
void is_leap_year(int year)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
//When year is leap year
printf("%d is a leap year", year);
}
else
{
printf("%d is not a leap year", year);
}
printf("\n");
}
int main()
{
//Test Case
is_leap_year(2020);
is_leap_year(2018);
is_leap_year(2025);
is_leap_year(2050);
is_leap_year(2032);
is_leap_year(2100);
return 0;
}``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````/*
Java Program
Check leap year
*/
class MyMaths
{
//Function which is check whether given year is leap year or not
public void is_leap_year(int year)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
//When year is leap year
System.out.print("\n" + year + " is a leap year" );
}
else
{
System.out.print("\n" + year + " is not a leap year");
}
}
public static void main(String[] args)
{
MyMaths obj = new MyMaths();
//Test Case
obj.is_leap_year(2020);
obj.is_leap_year(2018);
obj.is_leap_year(2025);
obj.is_leap_year(2050);
obj.is_leap_year(2032);
obj.is_leap_year(2100);
}
}``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````/*
C++ Program
Check leap year
*/
#include<iostream>

using namespace std;
class MyMaths
{
public:
//Function which is check whether given year is leap year or not
void is_leap_year(int year)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
cout << "\n" << year << " is a leap year";
}
else
{
cout << "\n" << year << " is not a leap year";
}
}
};
int main()
{
MyMaths obj =  MyMaths();
//Test Case
obj.is_leap_year(2020);
obj.is_leap_year(2018);
obj.is_leap_year(2025);
obj.is_leap_year(2050);
obj.is_leap_year(2032);
obj.is_leap_year(2100);
return 0;
}``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````<?php
/*
Php Program
Check leap year
*/
class MyMaths
{
//Function which is check whether given year is leap year or not
function is_leap_year(\$year)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (\$year % 4 == 0 && ((\$year % 100 != 0) || \$year % 400 == 0))
{
echo "\n". \$year ." is a leap year";
}
else
{
echo "\n". \$year ." is not a leap year";
}
}
}

function main()
{
\$obj = new MyMaths();
//Test Case
\$obj->is_leap_year(2020);
\$obj->is_leap_year(2018);
\$obj->is_leap_year(2025);
\$obj->is_leap_year(2050);
\$obj->is_leap_year(2032);
\$obj->is_leap_year(2100);
}
main();``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````/*
Node Js Program
Check leap year
*/
class MyMaths
{
//Function which is check whether given year is leap year or not
is_leap_year(year)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
process.stdout.write("\n" + year + " is a leap year");
}
else
{
process.stdout.write("\n" + year + " is not a leap year");
}
}
}

function main()
{
var obj = new MyMaths();
//Test Case
obj.is_leap_year(2020);
obj.is_leap_year(2018);
obj.is_leap_year(2025);
obj.is_leap_year(2050);
obj.is_leap_year(2032);
obj.is_leap_year(2100);
}
main();``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````/*
C# Program
Check leap year
*/
using System;
class MyMaths
{
//Function which is check whether given year is leap year or not
public void is_leap_year(int year)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
Console.Write("\n" + year + " is a leap year");
}
else
{
Console.Write("\n" + year + " is not a leap year");
}
}
public static void Main(String[] args)
{
MyMaths obj = new MyMaths();
//Test Case
obj.is_leap_year(2020);
obj.is_leap_year(2018);
obj.is_leap_year(2025);
obj.is_leap_year(2050);
obj.is_leap_year(2032);
obj.is_leap_year(2100);
}
}``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````#   Python 3 Program
#   Check leap year

class MyMaths :
# Function which is check whether given year is leap year or not
def is_leap_year(self, year) :
#  Check if Year is divisible by 4 or not
#  If year is divisible by 4, then check two case
#  Case 1 : Check if year is divisible by 100 or not
#  Case 2 : Check if Year is divisible by 400 or not
#  If any one case true then year is leap year
if (year % 4 == 0 and((year % 100 != 0) or year % 400 == 0)) :
print("\n", year ," is a leap year", end = "")
else :
print("\n", year ," is not a leap year", end = "")

def main() :
obj = MyMaths()
# Test Case
obj.is_leap_year(2020)
obj.is_leap_year(2018)
obj.is_leap_year(2025)
obj.is_leap_year(2050)
obj.is_leap_year(2032)
obj.is_leap_year(2100)

if __name__ == "__main__": main()``````

#### Output

`````` 2020  is a leap year
2018  is not a leap year
2025  is not a leap year
2050  is not a leap year
2032  is a leap year
2100  is not a leap year``````
``````#   Ruby Program
#   Check leap year

class MyMaths

# Function which is check whether given year is leap year or not
def is_leap_year(year)

#  Check if Year is divisible by 4 or not
#  If year is divisible by 4, then check two case
#  Case 1 : Check if year is divisible by 100 or not
#  Case 2 : Check if Year is divisible by 400 or not
#  If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))

# When year is leap year
print("\n", year ," is a leap year")
else

print("\n", year ," is not a leap year")
end
end
end
def main()

obj = MyMaths.new()
# Test Case
obj.is_leap_year(2020)
obj.is_leap_year(2018)
obj.is_leap_year(2025)
obj.is_leap_year(2050)
obj.is_leap_year(2032)
obj.is_leap_year(2100)
end
main()``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````/*
Scala Program
Check leap year
*/
class MyMaths
{
//Function which is check whether given year is leap year or not
def is_leap_year(year: Int): Unit = {
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
//When year is leap year
print("\n" + year + " is a leap year");
}
else
{
print("\n" + year + " is not a leap year");
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: MyMaths = new MyMaths();
//Test Case
obj.is_leap_year(2020);
obj.is_leap_year(2018);
obj.is_leap_year(2025);
obj.is_leap_year(2050);
obj.is_leap_year(2032);
obj.is_leap_year(2100);
}
}``````

#### Output

``````2020 is a leap year
2018 is not a leap year
2025 is not a leap year
2050 is not a leap year
2032 is a leap year
2100 is not a leap year``````
``````/*
Swift Program
Check leap year
*/
class MyMaths
{
//Function which is check whether given year is leap year or not
func is_leap_year(_ year: Int)
{
// Check if Year is divisible by 4 or not
// If year is divisible by 4, then check two case
// Case 1 : Check if year is divisible by 100 or not
// Case 2 : Check if Year is divisible by 400 or not
// If any one case true then year is leap year
if (year % 4 == 0 && ((year % 100 != 0) || year % 400 == 0))
{
print("\n", year ," is a leap year", terminator: "");
}
else
{
print("\n", year ," is not a leap year", terminator: "");
}
}
}
func main()
{
let obj: MyMaths = MyMaths();
//Test Case
obj.is_leap_year(2020);
obj.is_leap_year(2018);
obj.is_leap_year(2025);
obj.is_leap_year(2050);
obj.is_leap_year(2032);
obj.is_leap_year(2100);
}
main();``````

#### Output

`````` 2020  is a leap year
2018  is not a leap year
2025  is not a leap year
2050  is not a leap year
2032  is a leap year
2100  is not a leap year``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.