Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which loop is guaranteed to execute at least once?

  • A.for
  • B.while
  • C.do while
  • D.None of the above

Answer: C

Correct answer: do while

A do-while tests its condition after the body, so the body always runs at least once. for and while test first, and so may not run at all. This makes do-while the natural choice for reading input and then validating it.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.