Write a C# Sharp program to find whether a given year is a leap year or not. - Amit Notes

Latest

May 31, 2021

Write a C# Sharp program to find whether a given year is a leap year or not.

Write a C# Sharp program to find whether a given year is a leap year or not.

Pictorial Presentation:

Sample Solution:-

C# Code 

using System; { public static void Main() { int chk_year; Console.Write("\n\n"); Console.Write("Check whether a given year is leap year or not:\n"); Console.Write("----------------------------------------------"); Console.Write("\n\n"); Console.Write("Input an year : "); chk_year= Convert.ToInt32(Console.ReadLine()); if ((chk_year % 400) == 0) Console.WriteLine("{0} is a leap year.\n", chk_year); else if ((chk_year % 100) == 0) Console.WriteLine("{0} is not a leap year.\n", chk_year); else if ((chk_year % 4) == 0) Console.WriteLine("{0} is a leap year.\n", chk_year); else Console.WriteLine("{0} is not a leap year.\n", chk_year); } }


Sample Output

Check whether a given year is leap year or not: ---------------------------------------------- Input an year : 2017 2017 is not a leap year.


Flow Chart




------------------------------------------------------------------------------------------------

1.Read More about - C# Program to Perform Celsius to Fahrenheit Conversion.

2.Read More about - Check whether a number is a palindrome or not?

3.Read More about - C# Program to Reverse a String with Predefined Function.


No comments:

Post a Comment

If you have any doubts, Please let me know