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

Discussion

In the loop construct for(exp1; exp2; exp3), which part is always executed exactly once?

  • A.exp1
  • B.exp3
  • C.exp1 and exp3
  • D.exp1, exp2 and exp3

Answer: A

Correct answer: exp1

exp1, the initialisation, is evaluated once before the loop starts and never again. exp2, the condition, is evaluated before every pass - at least once, and once more than the body runs. exp3, the update, runs after each pass, so it may not run at all if the condition fails immediately.

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

Post your comment

Please log in or register to post a comment.