Go Program to Check Even or Odd

Any number that is divisible by 2 is an even number, and the remaining are odd numbers. This Go program uses the If else to check whether the given number is even or odd. Within the If condition (num % 2 == 0), we used the modulus (%) to check the remainder of num divided by 2 equals 0. If True, even number otherwise, an odd number.

package main

import "fmt"

func main() {

    var eonum int

    fmt.Print("Enter the Number to find Even or Odd = ")
    fmt.Scanln(&eonum)

    if eonum%2 == 0 {
        fmt.Println("\nIt is an Even Number")
    } else {
        fmt.Println("\nIt is an Odd Number")
    }
}
Go Program to Check Even or Odd 1