Ch. 5 Control Statements Part 2 Flashcards
Typically, _______ statements
are used for counter-controlled repetition and ______
statements for sentinel-controlled repetition.
for
while
The “do…while” statement test the loop-continuation condition ______ executing the loop’s body; therefore teh body always executes at least once.
after
The ______ statement selects among multiple actions based on the possible values of an integer variable or expression.
The ______ statement, when executed in a repetition statement, skips teh remaining statements in the loop body and proceeds with the next iteration of the loop.
continue statement
The _____ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
&&
(Conditional AND)
If the loop-continuation condition in a for header is initially ______, the program does not execute the for statements body.
false
Methods that perfrom common tasks and do not require objects are called ______ methods.
static methods
The default case is required in the switch selection statement.
False
the default case is optional
The break statement is required in the last case of a switch selection statement.
false
the break statement is used to exit the switch statement
The expression ( ( x > y) && ( a < b) )
is true if either x > y is true or a < b is ture
false
Both of the relational expressions must be true for the entire expression to be true when using && operator
The comma (,) formatting flag in a format specifier
(eg %,20.2f) indicates that a value should be output with a thousands seperator.
True
An expression containing “ll” operator is true if either or both of its operands are true
true
To test for a range of values in a switch statement, use a hyphen (-) between the start and end values of the range in a case lablel
False
The switch statement does not provide a mechanism for testing ranges of values, so every value that must be tested should be listed in a seperate case label
Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.
True