C# Function to determine whether the year is a leap year or not.Any year is entered through the keyboard.

/* C# Function to determine whether the year is a leap year or not.Any year is entered through the keyboard. */
using System;
public class Demo
{
    public static int find(int a)
    {
        int i = 0;
        if((a % 4 & a % 100 & a % 400) == 0)
            i = 1;
        else
            i = 0;
        return i;
    }

    public static void Main(string[] args)
    {
        int year, leap;
        Console.WriteLine("Enter an year : ");
        year = Convert.ToInt32(Console.ReadLine());
        leap = find(year);
        if(leap == 1)
            Console.WriteLine("{0} year is leap year ", year);
        else
            Console.WriteLine("{0} year is not a leap year ", year);
        Console.ReadLine();
    }
}

Output :
Enter an year :
2016

2016 year is leap year



Leave a comment