create an if statement with an else if and else with a condition of type int in go

main.go
package main

import (
    "fmt"
)

func main() {
    num := 10

    if num > 10 {
        fmt.Println("Number is greater than 10")
    } else if num < 10 {
        fmt.Println("Number is less than 10")        
    } else {
        fmt.Println("Number is equal to 10")
    }
}
277 chars
18 lines

In the above code, we first declare a variable num with a value of 10. Then, we create an if statement with a condition num > 10. If the condition is true, it prints "Number is greater than 10". If the condition is false, the else if statement is checked with the condition num < 10. If the else if condition is true, it prints "Number is less than 10". Finally, if none of the above conditions are true, the else block gets executed and it prints "Number is equal to 10".

gistlibby LogSnag