Preview

Computer science chapter 7 review

Good Essays
Open Document
Open Document
610 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Computer science chapter 7 review
A.P. Computer Science
Chapter 7 Review

1. Give two examples of control statements that are generally expected to execute repeatedly.
Loop and while
2. Give a reason for describing the Loop statement as a counted loop.
You can count how many times it’s going to loop
3. If a block of program code is composed of nested Loop statements and the outer loop count is 3 and the inner loop count is 6, how many times does the inner loop execute?
18 times
4. A Loop in which the count is infinity must, of course, eventually stop. What action triggers the stop of a so-called infinite loop?
Turn of the computer, or do something physically that causes the program to stop working. Also, stack overflow may occur, but technically if an infinite loop is stopped by such an event it’s not really infinite
5. What distinguishes a Loop control construct from a While control construct, in terms of what is known about the number of times the block of code will be repeated?
The loop statement will continue to run until a certain condition is met, and the while statement will continue to run while a certain condition is still true. You can tell the number of times a loop statement will repeat itself, while you are unable to tell for the while statement.
6. Conditional expressions used in a While statement have the same components as conditional expression used in what other control construct? boolean 7. Although in some programs a While statement should be infinite, in most programs a While statement should eventually end. How can you make sure that a While statement will eventually end? make sure the condition will become false eventually
8. Is it possible that the instructions within a While statement might never be executed at all? Give an example.
Yes. The condition might be false before the while statement is even executed. For example, if a while statement only works if an object is 3 meters away from another object, and the distance between the two objects is

You May Also Find These Documents Helpful