Write a program in C# that tells whether a given year is a leap year or not.
Following is the simple C# code :
Following is the simple C# code :
class Lab { static void Main(string[] args) { int year; Console.Write("Enter a year : "); year = Convert.ToInt32(Console.ReadLine()); if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { Console.WriteLine("{0} is a Leap Year", year); } else { Console.WriteLine("{0} is not a Leap Year", year); } Console.ReadLine(); } }
Output:-
No comments:
Post a Comment
Note: only a member of this blog may post a comment.