Friday 3 May 2019

Go Language: Use for loop as while loop


Example
for i <= 10 {
         fmt.Println("i : ", i)
         i++
}

App.go
package main

import "fmt"

func main() {
 i := 0

 for i <= 10 {
  fmt.Println("i : ", i)
  i++
 }
}


Output

i :  0
i :  1
i :  2
i :  3
i :  4
i :  5
i :  6
i :  7
i :  8
i :  9
i :  10



Previous                                                 Next                                                 Home

No comments:

Post a Comment