Question 1Easy
Which loop keyword does Go provide?
- for, while and do-while
- for and while
- Only for
- for and foreach
Answer: C. Only for
Explanation
Go has just for. A condition-only for cond {} acts like while, and for range iterates collections.
Step-by-step solution
for init; cond; post {}is the classic loop.for cond {}replaces while.for range x {}replaces foreach.
Why the other options are wrong
- A. Go has neither while nor do-while.
- B. There is no while keyword.
- D. There is no foreach keyword.