0% found this document useful (0 votes)
3 views2 pages

Que 5

The document provides a C# console program that checks if a given year is a leap year. It prompts the user to enter a year, validates the input, and uses the DateTime.IsLeapYear method to determine and display whether the year is a leap year or not. If the input is invalid, it prompts the user to enter a valid whole number year.

Uploaded by

Swarup Atigre
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Que 5

The document provides a C# console program that checks if a given year is a leap year. It prompts the user to enter a year, validates the input, and uses the DateTime.IsLeapYear method to determine and display whether the year is a leap year or not. If the input is invalid, it prompts the user to enter a valid whole number year.

Uploaded by

Swarup Atigre
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical Number :

05 Roll No : 1615

Que 5) Write a console program to accept year and check it is leap year
or not.
using System;

using [Link];

using [Link];

using [Link];
using [Link];

namespace vinishaq5

class Program
{

public static void Main(string[ ] args)

[Link]("Enter a year to check if it's a leap year:");

string input = [Link]();

int year;
if ([Link](input, out year))

if ([Link](year))

[Link]($"{year} is a leap year.");

else

[Link]($"{year} is not a leap year.");

}
}

else

[Link]("Invalid input. Please enter a valid year (a whole


number).");

[Link]("Press any key to exit.");


[Link]();

Output of the Code :

You might also like