Skip to content

Instantly share code, notes, and snippets.

@Vitosh
Created February 17, 2023 16:12
Show Gist options
  • Save Vitosh/b1634a83a2868466f6f9f959b3785808 to your computer and use it in GitHub Desktop.
Save Vitosh/b1634a83a2868466f6f9f959b3785808 to your computer and use it in GitHub Desktop.
For-While-Do-While-Loops-In-Golang.go
package main
import (
"fmt"
)
func main() {
fmt.Println("for-loop:")
ii := 1
for ii < 100 {
fmt.Println(ii)
ii++
}
fmt.Println("while do loop:")
i := 1
for i < 5 {
fmt.Println(i)
i++
}
fmt.Println("do while loop:")
j := 10
expression := true
for ok := true; ok; ok = expression {
fmt.Println(j)
j++
if j > 5 {
expression = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment