Executing a continue statement in C causes the program to jump to the end of the current

Question:

Executing a continue statement in C causes the program to jump to the end of the current loop iteration. The stated rule for translating a for loop into a while loop needs some refinement when dealing with continue statements. For example, consider the following code:

/* Example of for loop containing a continue statement */ /* Sum even numbers between 0 and 9 */ long sum= 0;

A. What would we get if we naively applied our rule for translating the for loop into a while loop? What would be wrong with this code?

B. How could you replace the continue statement with a goto statement to ensure that the while loop correctly duplicates the behavior of the for loop?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question

Computer Systems A Programmers Perspective

ISBN: 9781292101767

3rd Global Edition

Authors: Randal E. Bryant, David R. O'Hallaron

Question Posted: