VB.Net Program to Check the Given Year Is Leap Year or Not Using Conditional Operator

You are currently viewing VB.Net Program to Check the Given Year Is Leap Year or Not Using Conditional Operator

VB.Net program to check the given year is leap year or not using conditional operator

'VB.Net program to check the given year is 
'Leap year or not.

Module Module1

    Sub Main()

        Dim year As Integer = 0
        Dim result As String

        Console.Write("Enter the year: ")
        year = Integer.Parse(Console.ReadLine())

        result = If(((year Mod 4 = 0) AndAlso Not (year Mod 100 = 0)) OrElse
                ((year Mod 4 = 0) AndAlso (year Mod 100 = 0) AndAlso (year Mod 400 = 0)),
                      "Entered is Leap Year",
                      "Entered is not Leap Year"
                    )

        Console.WriteLine(result)

    End Sub

End Module

Output

Enter the year: 2004
Entered is Leap Year
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply