Go if else statements
Go if else statements
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
package main
import (
	"fmt"
	// "strconv"
	// "math"
	// "reflect"
)
func ifelsestatements()  {
	statePopulation := make(map[string]int)
    statePopulation = map[string]int{
        "California": 2341232,
        "Texas": 3341232,
        "Florida": 4341232,
        "New York": 5341232,
        "Illinois": 6341232,
        "Ohio": 7341232,
	}
	fmt.Printf("%v\n", statePopulation)
	if population, ok := statePopulation["California"]; ok {
		fmt.Printf("Population of California is: %v\n", population)
	}
	number := 50
	guess := -1
	if guess < 1 {
		fmt.Printf("The guess must be grater than 1!\n")
	}else if guess > 100 {
		fmt.Printf("The guess must be less than 100!\n")
	}else {
		if guess < number {
			fmt.Printf("Too low!\n")
		}
		if guess > number {
			fmt.Printf("Too high\n")
		}
		if guess == number {
			fmt.Printf("Equal\n")
		}
	}
myNum := 0.223456789
	if math.Abs(myNum / math.Pow(math.Sqrt(myNum), 2) -1) < 0.001 {
		fmt.Printf("These are the same!\n")
	} else {
		fmt.Printf("These are different!\n")
	}
}
func main()  {
	// arrays()
	// slices()
	// maps()
	// structs()
	// embedding()
	ifelsestatements()
}
 This post is licensed under  CC BY 4.0  by the author.
