initial commit

This commit is contained in:
specCon18 2023-12-18 03:40:05 -05:00
commit 493ce92e02
62 changed files with 1213 additions and 0 deletions

35
if-else/if-else.go Normal file
View file

@ -0,0 +1,35 @@
package main
import "fmt"
func main(){
//There are no ternary ifs in go
//basic if else
if 7%2 == 0 {
fmt.Println("7 is even")
} else {
fmt.Println("7 is odd")
}
//if doesnt need else
if 8%4 == 0 {
fmt.Println("8 is divisible by 4")
}
//You can use logical operators in if such as && and ||
if 7%2 == 0 || 8%2 == 0 {
fmt.Println("either 8 or 7 are even")
}
//a statement can precede conditionals;
// any variables declared in the statement
//are avalible in the current and all subsequent branches.
if num := 9; num < 0 {
fmt.Println(num, "is negative")
} else if num < 10 {
fmt.Println(num, "has 1 digit")
} else {
fmt.Println(num, "has multiple digits")
}
}