click below
click below
Normal Size Small Size show me how
03 mod 6
| Question | Answer |
|---|---|
| used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends | Repetition structures, or loops |
| The process of performing the same task over and over again is called __________, and C++ provides builtin iteration functionality. | iteration |
| What are the forms of repetition statements | • while structure • for structure • do-while structure |
| The condition being tested can be evaluated at either (1) the beginning or (2) the end of the repeating section of code. | True |
| If the test occurs at the beginning of the loop, the type of loop is called a ________________- | pre-test loop or entrance controlled loop. |
| If the test occurs at the end of the loop, the type of loop is called a _____________-- | post-test loop or exit-controlled-loop |
| the name of a control variable (or loop counter) | Counter-Controlled Repetition |
| the initial value of the control variable | Counter-Controlled Repetition |
| the loop-continuation condition that tests for the final value of the control variable to determine when to exit | Counter-Controlled Repetition |
| the control variable to be incremented (or decremented) each time through the loop | Counter-Controlled Repetition |
| used for repeating a statement or series of statements as long as a given conditional expression evaluates to true | for statement |
| condition is tested first (pre-test loop) | for statement |
| for (initialization; condition; update statement){ statement(s); } | for statement |
| used for repeating a statement or series of statements as long as a given conditional expression is evaluated to true. | while statement |
| condition is tested first (pre-test loop) | while statement |
| while( condition expression){ statement(s); | while statement |
| the name of a control variable ✓ asterisk | required in counter controlled repetition |
| the loop-continuation ✓ asterisk<=n | required in counter controlled repetition |
| executes a statement or statements then repeats the execution as long as a given conditional expression evaluates to true | do while statement |
| Statements in the loop are executed first at least once, and condition is tested last (post-test loop) | do while statement |
| used inside loops. | continue statement |
| TRUE OR FALSE. When a continue statement is encountered inside a loop, control jumps to the beginning of the loop for next iteration, skipping the execution of statements inside the body of loop for the current iteration | True |
| It is used to come out of the loop instantly | Break statement |
| TRUE OR FALSE. When a break statement is encountered inside a loop, the control directly comes out of loop and the loop gets terminated | Break statement |
| It is used with if statement, whenever used inside loop. | Break statement |
| It allows making an absolute jump to another point in the program | Goto statement |
| You should use this feature carefully since its execution ignores any type of nesting limitation | Goto statement |
| TRUE OR FALSE. The destination point is identified by a label, which is then used as an argument for the goto instruction | True |
| A ___________is made of a valid identifier followed by a colon (:) | label |
| A loop becomes infinite loop if a condition never becomes false. | Infinite loop |
| A loop inside another loop is called a ______. The number of loops depend on the complexity of a problem | Nested loop |