Skip to content

Commit 7156111

Browse files
Exercise 6: if else statements in go
1 parent 98bc056 commit 7156111

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ifelse.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
7+
if 7 % 2 == 0 {
8+
fmt.Println("7 is even")
9+
} else {
10+
fmt.Println("7 is odd")
11+
}
12+
13+
if 8%4 == 0 {
14+
fmt.Println("8 is divisible by 4")
15+
}
16+
17+
if num := 9; num < 0 {
18+
fmt.Println("num is negative")
19+
} else if num < 10 {
20+
fmt.Println("num is a singe digit")
21+
} else {
22+
fmt.Println("num is multiple digits")
23+
}
24+
}

0 commit comments

Comments
 (0)