18 lines
351 B
Go
18 lines
351 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
// Initialize the variable before the loop
|
|
value := 0
|
|
|
|
for i := 0; i < 5; i++ {
|
|
// Change its value within the loop
|
|
value += i
|
|
fmt.Println("Current Value:", value) // Use the variable here
|
|
}
|
|
|
|
fmt.Println("Final Value:", value) // Still accessible after the loop
|
|
}
|
|
|