PRACTICE / UNDERSTAND / REPEAT

Go: Control flow

Practice control flow with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

30 questionsAnswers explainedFree · no login
Question 1 of 30
Control flow · MCQQuestion link ↗

What sum does this Go for loop print?

total := 0
for i := 1; i <= 1; i++ { total += i }
fmt.Println(total)
Choose one answer
Answer & explanation

Answer: 1

The loop adds all integers from 1 through n.