Check number is odd or even on Go language

package main import ( "fmt" "os" "strconv" ) func main() { i, err := strconv.Atoi(os.Args[1]) if err != nil { fmt.Printf("couldn't convert number: %v\n", err) return } if i == 0 { fmt.Println("Number is Zero") }else if i%2 == 0 { fmt.Println(i, "is even") }else{ fmt.Println(i, "is odd") } }
This is a simple code to check number entered through cmdline args is odd or even. programming language: Go

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.