-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditions.go
65 lines (45 loc) · 968 Bytes
/
conditions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import "fmt"
func main(){
angka1 := 10
angka2 := 20
// if method
if (angka1<angka2) {
fmt.Println(angka1," lebih kecil ", angka2)
}else if(angka1>angka2){
fmt.Println(angka1, " lebih besar ", angka2)
}else{
fmt.Println(angka1, " sama dengan ", angka2)
}
//switch method
//single case
days := "wednesday"
switch days {
case "monday" :
fmt.Println("monday")
case "tuesday" :
fmt.Println("tuesday")
case "wednesday" :
fmt.Println("wednesday")
case "thursday" :
fmt.Println("thursday")
case "friday" :
fmt.Println("friday")
case "saturday" :
fmt.Println("saturday")
case "sunday" :
fmt.Println("sunday")
default :
fmt.Println("not a day")
}
// multi case
number := 1
switch number{
case 1,2,3 :
fmt.Println("positif number")
case -1,-2,-3 :
fmt.Println("negatif number")
default :
fmt.Println("non number")
}
}