Skip to content

Commit afd43b4

Browse files
committed
Reto #17 - go
1 parent 62d2caf commit afd43b4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
// This Go code snippet is using a `for` loop to iterate over the numbers from 1 to 10.
7+
for i := 1; i < 11; i++ {
8+
fmt.Printf("%d\n", i)
9+
}
10+
11+
// This code snippet in Go is creating an array named `loop` with a length of 10, where each element
12+
// is of type `uint` (unsigned integer).
13+
loop := [10]uint{}
14+
for i, _ := range loop {
15+
fmt.Printf("%d\n", i+1)
16+
}
17+
18+
// The code snippet you provided is using a `for` loop with a condition to iterate over the numbers
19+
// from 1 to 10. Here's a breakdown of what it does:
20+
index := 1
21+
for index < 11 {
22+
fmt.Printf("%d\n", index)
23+
index++
24+
}
25+
26+
// The code snippet `index = 1
27+
// for ; index < 11; index++ {
28+
// fmt.Printf("%d\n", index)
29+
// }` is using a `for` loop in Go to iterate over the numbers from 1 to 10. Here's a breakdown of what
30+
// it does:
31+
index = 1
32+
for ; index < 11; index++ {
33+
fmt.Printf("%d\n", index)
34+
}
35+
}

0 commit comments

Comments
 (0)