Chapter 5 Quiz

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Regarding the number of times nested loops execute. Statement A: the outer loop; Statement B: the inner loop; There is no relationship between statement A and B. Can't determine from question Statement A is the same as statement B. Statement A is greater than statement B. Statement B is greater than statement A.

Statement B is greater than statement A.

Which of the following is NOT a difference between the FOR and WHILE loop? An initialization statement may be used for a local variable in the FOR loop - not so with WHILE. An omitted test condition in a FOR loop is interpreted as True. Can't determine from question. The body of a FOR loop may be skipped depending upon the entry condition - not so with the WHILE. There is a slight difference in the body between the two loops if a CONTINUE statement is used.

The body of a FOR loop may be skipped depending upon the entry condition - not so with the WHILE.

To end a loop what condition must not be met? The loop must end. Control variable int i < size The test condition must not be met. If it loops - it works.

The test condition must not be met.

How do the 3 types of loops compare? The do-while and the while loops are pretest loops and the for loop is a post-test loop. The while loop and for loop are pretest loops and the do-while is a post-test loop. These are all pretest loops. The while loop is a pretest loop and the do-while loop is a post-test loop and the for loop is neither a post-test nor a pretest loop. The while loop is a pretest loop and the for loop and do-while loop are post-test loops.

The while loop and for loop are pretest loops and the do-while is a post-test loop.

Luther opens up a file and cannot read its contents. This is a ____ file. encoded hexadecimal binary output text

binary

Identify what kind of condition goes in an if statement end-logic statement switch declaration boolean expression operational comparative statement comparison

boolean expression

A variable that determines whether a loop body will execute is the loop ____ variable. sentinel supervisor control power counter

control

A ___ is a variable that is regularly incremented or decremented each time a loop iterates. counter or sentinel running total sentinel priming read counter

counter

A _____ is a variable that can be set to indicate whether some event has occurred. subscript counter flare banner flag

flag

In a WHILE loop ____. a boolean expression is evaluated - if it is true the loop is over the loop body always executes at least one time you need to declare and initialize the loop control variable inside the loop body. the boolean expression is always evaluated at least once. the loop body always consists of a single statement

the boolean expression is always evaluated at least once.

Comparing if-else and switch statements: C++ doesn't even have a switch statement - it's a case statement Can't determine from question the if-else is more versatile than the switch there is no practical difference between the two the switch is less efficient than the if-else

the if-else is more versatile than the switch

Within its parentheses, the FOR loop contains ____ parts that are separated by semicolons. as many as needed two four five three

three

Classify the operator is this code snippet: '++varname' trinary binary unary bitwise logical

unary

A WHILE loop is commonly used _____. in counting situations because you can place all relevant information in one location. in place of a subroutine call. when you don't know in advance precisely the number of times the loop will iterate When you need to start at a value other than zero. when you need to test a condition at the end of the loop body

when you don't know in advance precisely the number of times the loop will iterate

When we want ______ data, we use an ____ file. Can't determine from question. read, random write, input write, output read, output

write, output

If (x <= y) is true, then _____. x = y is true y <= x is true abs(x) == y is true x > y is false x >= y is false

x > y is false

The expression 43 > 100 equivalates to: 0 1 -1 -0 true

0

Distinguish which of these is a posttest loop A WHILE and FOR and a DO-WHILE A WHILE loop A DO-WHILE loop A FOR loop Can't determine from question

A DO-WHILE loop

Which of the following is a posttest loop? A WHILE loop. A FOR loop. A DO-WHILE loop. FOR-EACH All loops are posttest loops.

A DO-WHILE loop.

In which type of loop might the body never execute? A DO-WHILE loop A DO-WHILE but not a WHILE or FOR. A FOR loop A WHILE and FOR - but not DO-WHILE A WHILE loop

A WHILE and FOR - but not DO-WHILE

Two relational expressions are joined with a &&. This is a logical ___. OR operator XOR operator Invalid C++ operator NOT operator AND operator

AND operator

The = operator determines whether the operand is what? On its upper axis to the operand on the left. On its right is equal to the operand on the left. On its left is equal to the operand on its right. On its back axis to the operand on the head. What value is assigned to a variable.

What value is assigned to a variable.

Which of the following is false? You can block many actions under the ELSE in an IF-ELSE even though the IF executes only a single statement. You can have an IF without an ELSE. An IF-ELSE statement can be written on a single line. You could write an IF-ELSE statement that uses no semicolons between the location of the IF and the location of the ELSE. You can simulate an IF-ELSE statement with two IF statements and a NOT statement.

You could write an IF-ELSE statement that uses no semicolons between the location of the IF and the location of the ELSE.

A client enters bad data for a program. The program will automatically ____. attempt to process the data and correct it if necessary filter out the bad data and exit filter out the bad data and reprompt the client add an entry to a log file and terminate attempt to process the bad data and may crash.

attempt to process the bad data and may crash.

A FOR loop is commonly used ____. in place of a subroutine call. when you need a loop in main(). when you don't know in advance precisely the number of times the loop will iterate. in counting situations because you can place all relevant information in one location. when you need to test a condition at the end of the loop body.

in counting situations because you can place all relevant information in one location.

Loop B is within the body of loop A. Loop B is known as an _____ loop. control duplicate nested outer inner

inner

When a loop is contained withing another loop, the loops are ____. not allowed in C++ switched cased nested shelled

nested

Reading console or file input, we often use a ____ before the WHILE loop to accept the first input value to test. priming entry priming read number primary number user entry

priming read

When we want _____ data, we use an _____ file read, input can't determine from question write, input read, output write, sequential

read, input

A ___ is a sum of numbers that accumulates with each iteration of a loop. counter sentinel counter or sentinel priming read running total

running total

A ___ is a special value that marks the end of a list of values. counter or sentinel sentinel priming read counter running total

sentinel

Luther opens up a file and can read it's contents. This is a _____ file. encoded output text binary hexadecimal

text


Set pelajaran terkait

NUR 165 Ch 22 Workbook Practice Questions TEST 3

View Set

Exam 2: Antibodies, BCR, B cell Development, B cell immunity

View Set

Module 7: Section E Social Engineering

View Set

Chapter 3: Colonial Ways of Life

View Set

abeka vocabulary spelling poetry V quiz 2A

View Set

Science//Respiration//Photosynthesis

View Set

Chapter 4: Human Digestion, Absorption, and Transport

View Set