top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to find if the Year is Leap Year or Not in C# ?

0 votes
31 views
How to find if the Year is Leap Year or Not in C# ?
posted May 24, 2016 by Latha

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

4 Answers

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

namespace AbundantcodeConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            // How to Check if the year is leap year or not
            int input = 1996;
            if(input %100 ==0)
            {
                if(input%400==0)
                {
                    Console.WriteLine("Leap Year");
                }
                else
                {
                    Console.WriteLine("Not a Leap Year");
                }
            }
            else
            {
                if(input %4 ==0)
                {
                    Console.WriteLine("Leap Year");
                }
                else
                {
                    Console.WriteLine("Not a Leap Year");
                }
            }
            Console.ReadLine();
        }
    }    
}
answer May 24, 2016 by Shivaranjini
0 votes
using System;
namespace Ashok
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the year");
            int i = int.Parse(Console.ReadLine());
            Console.WriteLine($"year is {((i % 4 == 0) ? "leap" : "not leap")} year.");
            Console.ReadLine();
        }
    }
}
answer 5 days ago by Rushabh Verma R.
0 votes
using System;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the year");
            int i = int.Parse(Console.ReadLine());
            Console.WriteLine($"year is {((i % 4 == 0) ? "leap" : "not leap")} year.");
            Console.ReadLine();

        }
    }
}
answer 5 days ago by anonymous
0 votes
using System;

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the year");

            bool ashok = DateTime.IsLeapYear(int.Parse(Console.ReadLine()));
            Console.WriteLine(ashok);
            Console.ReadLine();

        }
    }
}
answer 4 days ago by Rushabh Verma R.
Similar Questions
0 votes
public class Semaphore
{
private object _mutex = new object;
private int _currAvail;
public Semaphore(int capacity)
{
_currAvail = capacity;
}
public void Wait()
{
lock(_mutex)
{
if ( currAvail == 0) Monitor.Wait(_mutex);
_currAvail --;
}
}
public void Signal()
{
lock(_mutex)
{
_currAvail ++;
Monitor.Pulse(_mutex);
}
}
}
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...