QuestionQ254

VerifiedControl Flow – Conditional Blocks and Loops

How many stars does the following code print to the monitor?

Question Image

Explanation

A left shift by one bit doubles the value of x. The loop prints once for x values 1, 2, 4, and 8; after that, x becomes 16, which does not satisfy x < 10. Thus, it prints four stars.

Community Discussion

No comments yet. Be the first to start the discussion!