Pages

Search This Blog

Leap Year Using Logical Operators


Module leap_yr
    Sub main()
        Dim y As Integer
        Console.Write("Enter Year:")
        y = CInt(Console.ReadLine())
        If y Mod 4 = 0 And y Mod 100 <> 0 Or y Mod 400 = 0 Then
            Console.WriteLine("the year " + y.ToString + " is a leap year")
        Else
            Console.WriteLine("the year " + y.ToString + " is a NOT leap year")
        End If
        Console.ReadLine()
    End Sub
End Module

1 comment: