LearnFrenzy
Sign in Take a free test

C Loops · Loops MCQ · Question 10

while (1) vs for (;;) in C Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links