Leap year program

Leap year program in c

#include<stdio.h>
#include<conio.h>
void CheckLeapYear(int year);
void main()
{
	int year;
	printf("Enter the year \n");
	scanf("%d",&year);
	CheckLeapYear(year);
	getch();
}
void CheckLeapYear(int year)
{
	if(year%400==0)
	{
		printf("This year is leap year");
	}
	else if(year%100==0)
	{
		printf("This year is not leap year");
	}
	else if(year%4==0)
	{
		printf("This year is leap year");
	}
	else
	{
		printf("This year is not leap year");
	}
}

Output

Enter the year
2020
This year is leap year

Leap year program in c++

#include<iostream>
#include<conio.h>
using namespace std;
class FindLeapYear
{
public:
	void CheckLeapYear(int year)
	{
		if(year%400==0)
		{
			cout<<"This year is leap year";
		}
		else if(year%100==0)
		{
			cout<<"This year is not leap year";
		}
		else if(year%4==0)
		{
			cout<<"This year is leap year";
		}
		else
		{
			cout<<"This year is not leap year";
		}
	}
};
void main()
{
	FindLeapYear fly;
	int year;
	cout<<"Enter the year \n";
	cin>>year;
	fly.CheckLeapYear(year);
	getch();
}

Output

Enter the year
2028
This year is leap year

Leap year program in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FindLeapYearProject
{
    class FindLeapYear
    {
        public void CheckLeapYear(int year)
        {
            if (year % 400 == 0)
            {
                Console.WriteLine("This year is leap year");
            }
            else if (year % 100 == 0)
            {
                Console.WriteLine("This year is not leap year");
            }
            else if (year % 4 == 0)
            {
                Console.WriteLine("This year is leap year");
            }
            else
            {
                Console.WriteLine("This year is not leap year");
            }
        }
        static void Main(string[] args)
        {
            FindLeapYear fly = new FindLeapYear();
            Console.WriteLine("Enter the year");
            int year = Convert.ToInt32(Console.ReadLine());
            fly.CheckLeapYear(year);
            Console.ReadLine();
        }
    }
}

Output

Enter the year
2400
This year is leap year

Leap year program in java

import java.util.*;
class examples
{
    public void CheckLeapYear(int year)
    {
        if (year % 400 == 0)
        {
        	System.out.println("This year is leap year");
        }
        else if (year % 100 == 0)
        {
        	System.out.println("This year is not leap year");
        }
        else if (year % 4 == 0)
        {
        	System.out.println("This year is leap year");
        }
        else
        {
        	System.out.println("This year is not leap year");
        }
    }
public static void main(String[] args)
	{
	examples ex=new examples();
	Scanner sc=new Scanner(System.in);
	System.out.println("Enter the year");
	int year=sc.nextInt();
	ex.CheckLeapYear(year);
	}
}

Output

Enter the year
2035
This year is not leap year

Write a comment


Name Email Message