How to replace the early termination code


Discussion:

Q: How to eliminate a break statement from a for loop

Using the following code as an example, explain how, in general, one can remove the break statement and replace it with "better" code:

int count; for (count = 1; count <= 10 ; ++count) { if (count == 5) break; // LINE 5 };

Suppose we replace the line labeled "LINE 5" with a continue statement. How would you replace the early termination code with "better" structured code?

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: How to replace the early termination code
Reference No:- TGS01938004

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)