Concept explainers
A criticism of the break statement and the continue statement is that each is unstructured. Actually, break statements and continue statements can always be replaced by structured statements, although doing so can be awkward. Describe in general how you would remove any break statement from a loop in a
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
C How to Program (8th Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Computer Science: An Overview (12th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Starting Out with Java: Early Objects (6th Edition)
- A criticism of the break statement and the continue statement is that each is unstructured.Actually, break statements and continue statements can always be replaced by structured statements, although doing so can be awkward. Describe in general how you would remove any breakstatement from a loop in a program and replace that statement with some structured equivalent.[Hint: The break statement leaves a loop from within the body of the loop. The other way to leaveis by failing the loop-continuation test. Consider using in the loop-continuation test a second testthat indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here toremove the break statement from the program of Fig. 4.11arrow_forward12. In .............., the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other. a. Loop unrolling b. Strength reduction c. Loop concatenation d. Loop jammingarrow_forwardConsider the following for loop. int j, s;s = 0;for (j = 1; j <= 10; j++)s = s + j * (j - 1);In this for loop, identify the loop control variable, the initialization statement, loop condition, the update statement, and the statement that updates the value of s.arrow_forward
- Complete the following sentence. There are two basic forms of loop constructs: while loops and loops.arrow_forwardExplain the difference between 'while loop' and 'do while loop' with an example for each one.arrow_forwardAnswer the following sentences true or false 1. The main difference between a do-while loop and the while loop is in the do-while loop the condition is tested at the end of the loop body. 2. In while loop, if the condition is not true, then the body of a loop will not be executed, not even once. 3. If you want to print from 10, then assign the value 0 during initialization.arrow_forward
- Implement programs involving the use of while, do..while and for loop statement. Objectives: Topics Covered: Implementing programs using loops. Description FRIDAY THE 13TH When will Friday the 13th occur in 1990? Write a program that will find all months in 1990 in which the 13th falls on a Friday. You need to know the following. 1. January 1, 1990 was on a Monday. 2. September, April, June, and November have thirty days, all the rest have 31 except for February which has 28 except in leap years when it has 29. 3. 1990 is not a leap year. Note: To make it fair for everyone, you may not use any built-in date functions from your computer language. Sample Output if Applicable Sample Run In 1990, Friday the 13th occurs in the months: APRILarrow_forwardExplain the main difference between a while-loop and a for-loop? When would you used one over the other?arrow_forwardWhat are the differences between while and for loops? Can you think of some examples of when a for loop would be the best structure to use?arrow_forward
- explain the use of voids and why do we use it. explain also if else loopsarrow_forwardCan you explain how a coder can spot and break out of a loop?arrow_forwardThe Issue: You are aware that the software breaks during the 487th loop iteration. You'll have to type continue 486 times before you get to the problem if you use a breakpoint.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr