Leap years

Report a typo

As you know, a regular year has 365 days, but a leap year has 366 days (the extra day is the 29th of February).

Create a Go program that evaluates the year variable using conditional statements and prints "Leap year" or "Regular year" depending if it's a leap or a regular year.

For a year to be considered a leap year, it must meet the following conditions:

  • A Leap year is any year that is divisible by 4, e.g., 2008,20122008, 2012 but not divisible by 100 e.g. 2100,22002100, 2200
  • However, if the year is divisible by 400, then it is a leap year: e.g., 2000,2400,28002000, 2400, 2800

Sample Input 1:

2008

Sample Output 1:

Leap year

Sample Input 2:

2100

Sample Output 2:

Regular year
Write a program in Go
package main

import "fmt"

func main() {
var year int
fmt.Scanln(&year)

if year%? == ? && year%? != ? || year%? == ? {
?
} else {
?
}
}
___

Create a free account to access the full topic