Go - for Loop

A for loop is a repetition manage structure. It allows you to write down a loop that needs to execute a specific range of instances Range] announcement(s);


package deal most important

import "fmt"

func major() 
   var b int = 12
   var a int
   numbers := [6]int5, 4, 3, 2 

   /* for loop execution */
   for a := zero; a < 10; a++ 
      fmt.Printf("cost of a: %dn", a)
   for a < b 
      fmt.Printf("fee of a: %dn", a)
   for i,x:= variety numbers 
      fmt.Printf("price of x = %d at %dn", x,i)

When the above code is compiled and executed, it produces the following result
$cross run important.Move
price of a: zero
price of a: 1
price of a: 2
cost of a: three
fee of a: four
value of a: five
value of a: 6
price of a: 7
price of a: 8
value of a: 9
value of a: 1
cost of a: 2
value of a: three
price of a: 4
value of a: five
price of a: 6
cost of a: 7
value of a: 8
fee of a: 9
value of a: 10
fee of a: 11
fee of a: 12
price of x = 5 at 0
fee of x = 4 at 1
price of x = 3 at 2
value of x = 2 at 3
cost of x = 0 at four
fee of x = zero at five