ifelse.go 407 B

12345678910111213141516171819202122
  1. package main
  2. import "fmt"
  3. func main() {
  4. var first int = 10
  5. var cond int
  6. if first <= 0 {
  7. fmt.Printf("first is less than or equal to 0\n")
  8. } else if first > 0 && first < 5 {
  9. fmt.Printf("first is between 0 and 5\n")
  10. } else {
  11. fmt.Printf("first is 5 or greater\n")
  12. }
  13. if cond = 5; cond > 10 {
  14. fmt.Printf("cond is greater than 10\n")
  15. } else {
  16. fmt.Printf("cond is not greater than 10\n")
  17. }
  18. }