Question 10
Back to Exercise
What is the difference between while (1) and for (;;)?
- A while (1) is faster
- B for (;;) is faster
- C None – both are infinite loops and compile to the same code Correct
- D for (;;) runs once
Correct Answer: Option C
Both are infinite loops, and compilers generate identical code. for (;;) is sometimes preferred because some older compilers warned about the constant condition in while (1).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!