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

Discussion

Translating a for loop with an initialisation, a test and an increment produces code in the order

  • A.body, test, increment, initialisation, label, jump back
  • B.initialisation, label, test, body, increment, jump back
  • C.label, initialisation, body, test, increment, jump back
  • D.test, initialisation, label, body, jump back, increment

Answer: B

Correct answer: initialisation, label, test, body, increment, jump back

The initialisation runs once and so precedes the label. The test guards entry to the body, and the increment runs after the body but before the test is repeated - which is why the jump goes back to the label rather than to the initialisation, and why a continue statement must jump to the increment rather than to the test.

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

Post your comment

Please log in or register to post a comment.