While loop



package main
import (
    "fmt"
    "time"
)

func main(){
    sum := 1
    for sum < 10 {
        sum += sum
        fmt.Println(sum)
        time.Sleep(300 * time.Millisecond)
    }
}
Remove the conditions and you get an infinite loop
import (
    "fmt"
    "time"
)

func main(){
    sum := 1
    for {
        sum += sum
        fmt.Println(sum)
        time.Sleep(300 * time.Millisecond)
    }
}

2 comments:

  1. Thanks for sharing this Information blog. Recently I have completed Php Training Courses in chennai at a leading Company. It's really useful for me to make a
    bright Future career. Visit Us,Php Training Institute Chennai. besant technologies reviews | besant technologies reviews | besant technologies reviews

    ReplyDelete