Look at this Go code. What will it print when run?
package main import "fmt" func main() { var x int = 5 var y int = 10 fmt.Println(x + y) }
Variables hold values that can be used in calculations.
The variables x and y hold numbers 5 and 10. Adding them prints 15.
Choose the best reason why variables are important in programming.
Think about how programs remember information.
Variables store data so the program can use or change it later. This makes programs flexible and dynamic.
What will this program print?
package main import "fmt" func main() { var count int = 3 count = count + 4 fmt.Println(count) }
Variables can change their value during the program.
The variable count starts at 3, then 4 is added, so it becomes 7.
What happens when you run this code?
package main import "fmt" func main() { var a int fmt.Println(a) }
In Go, variables have default values if not set.
Uninitialized int variables in Go default to 0, so it prints 0.
Which statement best explains how variables make code reusable?
Think about how changing variable values affects program behavior.
By using variables, the same code can process different inputs, making it reusable and flexible.