Title | 5 - chapter 5 |
---|---|
Author | Chung cxchen |
Course | Problem Solving & Prgmng I Lab |
Institution | Old Dominion University |
Pages | 4 |
File Size | 132.8 KB |
File Type | |
Total Downloads | 100 |
Total Views | 201 |
chapter 5...
Test 5
1.
2.
3.
4.
5.
6.
7.
The most common error associated with loops is a(n) ________ error. a. syntax b. infinite loop c. off-by-one d. bounds Which of the following is the syntax for using the eof function? a. istream.eof() b. eof().istreamVar c. istreamVar.eof() d. istreamVar().eof In a for structure, the ________ statement is executed after the continue statement, and before the loop condition executes. a. repeat b. break c. update d. end The function time is defined in the header file ________ . a. cstdlib b. iomanip c. cmath d. ctime A semicolon at the end of a for statement ________ the for loop. a. terminates b. repeats c. resets d. executes The function rand() is defined in the header file ________ . a. iostream b. cstdlib c. iomanip d. cmath In the statement, while (cin), the variable cin acts as the ________ . a. sentinel
8.
9.
10.
11.
12.
13.
b. counter c. index d. loop control variable The primary purpose of the ________ loop is to simplify the writing of counter-controlled loops. a. sentinel b. for c. nested d. do-while The ________ statement is an effective way to avoid extra variables to control a loop and produce elegant code. a. skip b. break c. continue d. switch When the ________ statement executes in a repetition structure, it immediately exits from the structure. a. break b. continue c. exit d. do The ________ loop is a pretest loop. a. do...while b. while c. indexed d. switch A ________ is a special value that marks the end of the input data. a. sentinel b. constant c. trigger d. switch When the ________ statement executes in a repetition structure, it skips the remaining statements in the loop and proceeds with the next iteration of the loop. a. break b. continue c. exit d. do
Which of the following is a Fibonacci sequence? a. 1,2,4,8,16,32 b. 1,1,2,3,5,8 c. 1,1,2,3,5,8 14.
15.
16.
17.
18.
19.
20.
0,1,0,2,0,1 d. 0,1,2,4,16,25 Which of the following statements is TRUE? a. If the loop condition in a for loop is initially false, the loop body does not execute. b. A for loop executes indefinitely if the loop condition is always false. c. In a for statement, if the loop condition is omitted, it is assumed to be false. d. C++ does not allow you to use fractional values for loop control variables that are real numbers. The ________ loop is a posttest loop. a. do...while b. while c. indexed d. for Putting one control structure inside another is called ________ . a. indexing b. looping c. nesting d. sequencing The C++ eof function is a member of the data type ________ . a. file b. istream c. cstdlib d. iomanip Which of the following is the general form of the do...while statement? a. do statement while (expression); b. do while statement (expression); c. do expression while (statement); d. do (statement); while expression When a program reads past the end of the input file, the expression ________ becomes false. a. eof.infile() b. infile.!eof
c. infile(eof) d. !infile.eof() ...