diff --git a/src/05-for.go b/src/05-for.go new file mode 100644 index 0000000..3bf7bfc --- /dev/null +++ b/src/05-for.go @@ -0,0 +1,28 @@ +package main + +import "fmt" + +func main() { + i := 1 + for i <= 3 { + fmt.Println("number i =", i) + i = i + 1 + } + + for j := 0; j < 3; j++ { + fmt.Println("number j =", j) + } + + for { + fmt.Println("loop with no condition") + break + } + + for n := range 6 { + if n%2 == 0 { + fmt.Println("even number n = ", n) + continue + } + fmt.Println("odd number n = ", n) + } +}