fix: `func main() { var year int fmt.scanln(&year) if year%400 == 0 && year%100 != 0 || year%4 == 0 { fmt.println("leap year") } else { fmt.println("regular year") } }` in go

To fix the provided code in Go, you need to make a few adjustments.

First, there is a typo in the fmt.scanln function. It should be changed to fmt.Scanln (with a capital S).

Second, the fmt.Println function should be changed to fmt.Println (with a capital P).

Here is the corrected code:

main.go
package main

import "fmt"

func main() {
    var year int
    fmt.Scanln(&year)
    
    if year % 400 == 0 && year % 100 != 0 || year % 4 == 0 {
        fmt.Println("leap year")
    } else {
        fmt.Println("regular year")
    }
}
237 chars
15 lines

With these modifications, the code should work correctly. It reads an integer input from the user and checks if it is a leap year or a regular year based on the conditions in the if statement. The result is then printed to the console.

gistlibby LogSnag