svetlozar_kirkov

Leap Year Check (Exercise)

Oct 7th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  1. using System;
  2.  
  3. class ConsoleTests
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter a year: ");
  8.         int year = int.Parse(Console.ReadLine());
  9.         DateTime check = new DateTime(year,01,01);
  10.         double numberOfDays = new DateTime(check.Year, 12, 31).Subtract(check).TotalDays;
  11.         Console.WriteLine(numberOfDays==364 ? "The year is not leap." : "The year is leap.");
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment