Go code
count := 0
for {
count++
if count == 2 {
break
}
}
fmt.Println(count)Line-by-line explanation
- Count starts at zero.
- For begins an endless loop.
- Count increases.
- The if finds 2 and break exits.
- The final count is displayed.
Expected output
2This is the expected result.