Sunday, October 2, 2022
HomeC#Program to examine whether or not the entered yr is Leap 12...

Program to examine whether or not the entered yr is Leap 12 months or Not ~ IT Tutorials with Instance


On this instance, we’ll study Learn how to discover the yr entered by the consumer is Leap 12 months or not. This is among the most typical interview questions which will be requested on the more energizing degree interview spherical.

I’ll suggest you to examine the under hyperlink for Prime C# Interview Applications requested throughout the Interview and Examination.

Let’s Start:

With the intention to discover the yr entered by the consumer is Bissextile year or not, we’ve got to examine first that the yr entered by the consumer is evenly divisible by 4. If the yr is evenly divisible by 4 in addition to evenly divisible by 100 then the yr entered by the consumer is just not a Bissextile year. In case if it is not evenly divisible by 100 then it’s an instance of Bissextile year. In case, If the yr is evenly divisible by 400 then that is an instance of the Bissextile year.

Program:

Console.WriteLine(“Enter
the yr to examine whether or not yr entered is Bissextile year or not?”
);

//Recieve enter yr from the consumer

int yearValue =
Convert.ToInt32(Console.ReadLine());

//If yr is evenly divisible by 4 as properly and never divisible by
100 then yr is bissextile year

//If yr is evenly divisible by 400 then yr is bissextile year

//Else not a Leap 12 months

if ((yearValue % 4 == 0 &&
yearValue % 100 != 0) || (yearValue % 400 == 0))

{

    Console.WriteLine(“{0} is a Leap 12 months”,
yearValue);

}

else {

    Console.WriteLine(“{0} is just not a Leap 12 months”, yearValue);

}

//Utilizing Console.ReadLine() as a way to maintain the terminal/command
immediate

Console.ReadLine();

Preview:

I hope this instance will allow you to in your interview/examination preparation.

Thanks

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments