-
Notifications
You must be signed in to change notification settings - Fork 1
/
switch.go
55 lines (53 loc) · 936 Bytes
/
switch.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
package main
import "fmt"
func main() {
var input int
fmt.Println("enter 1 for add two num")
fmt.Println("enter 2 for substract two num")
fmt.Println("enter 3 for multiply two num")
fmt.Println("enter 4 for devision ")
fmt.Println("press (1 or 2 or 3 or 4)")
fmt.Scanln(&input)
switch input {
case 1:
{
var a, b int
fmt.Println("enter a:")
fmt.Scanln(&a)
fmt.Println("enter b:")
fmt.Scanln(&b)
fmt.Println(a + b)
}
case 2:
{
var a, b int
fmt.Println("enter a:")
fmt.Scanln(&a)
fmt.Println("enter b:")
fmt.Scanln(&b)
fmt.Println(a - b)
}
case 3:
{
var a, b int
fmt.Println("enter a:")
fmt.Scanln(&a)
fmt.Println("enter b:")
fmt.Scanln(&b)
fmt.Println(a * b)
}
case 4:
{
var a, b int
fmt.Println("enter a:")
fmt.Scanln(&a)
fmt.Println("enter b:")
fmt.Scanln(&b)
fmt.Println(a / b)
}
default:
{
fmt.Println("wrong input")
}
}
}