A criticism of the break statement and the continue statement is that each is unstructured. Actually, these statements can always be replaced by structured statements, although doing so can be awkward. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement exits a loop from the body of the loop. The other way to exit is by failing the loop-continuation test. Consider using in the loop- continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the tech- nique you develop here to remove the break statement.

What will be an ideal response?

A loop can be written without a break by placing in the loop-continuation test a sec- ond test that indicates “early exit because of a ‘break’ condition.” Alternatively, the break can be replaced by a statement that makes the original loop-continuation test immediately false, so that the loop terminates

Computer Science & Information Technology

You might also like to view...

The operation for adding an item to a queue is called

A) requeue B) enqueue C) dequeue D) proqueue

Computer Science & Information Technology

Critical Thinking Questions Case 7-1 ? You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store uses a bar code reader to process items during checkout. What type of technology does the bar code reader use?

A. light sources B. sonar C. laser beams D. radio frequency

Computer Science & Information Technology