Filters
Question type

Study Flashcards

A statement that causes a loop to terminate early is


A) break
B) terminate
C) re-iterate
D) continue
E) None of these

F) A) and B)
G) B) and E)

Correct Answer

verifed

verified

What is the output of the following code segment? N = 1; While (n <= 5) Cout << n << ' '; N++;


A) 1 2 3 4 5
B) 1 1 ... and on forever
C) 1 2 3 4 5 6
D) 1 2 3 4
E) 2 3 4 5

F) All of the above
G) A) and B)

Correct Answer

verifed

verified

A while loop's body can contain multiple statements, as long as they are enclosed in braces.

A) True
B) False

Correct Answer

verifed

verified

To write data to a file, you define an object of the __________ data type.


A) outputFile
B) ifstream
C) fstream
D) ofstream

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n)


A) pre-test loop
B) post-test loop
C) null statement
D) infinite loop
E) None of these

F) A) and E)
G) B) and E)

Correct Answer

verifed

verified

What will the following code display? Int x = 0; For (int count = 0; count < 3; count++) X += count; Cout << x << endl;


A) 0
1
2
B) 0
C) 6
D) 3

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

A statement that may be used to stop a loop's current iteration and begin the next one is


A) break
B) terminate
C) re-iterate
D) continue
E) None of these

F) C) and D)
G) B) and E)

Correct Answer

verifed

verified

To allow file access in a program, you must use __________ in the header file.


A) #include file
B) #include fileaccess
C) #include fstream
D) #include cfile

E) A) and C)
F) B) and C)

Correct Answer

verifed

verified

This means to increase a value:


A) decrement
B) increment
C) modulus
D) parse
E) None of these

F) B) and E)
G) A) and B)

Correct Answer

verifed

verified

How many times will the following loop display "Looping again!"? For (int i = 0; i <= 20; i++) Cout << "Looping again!" << endl;


A) 20
B) 19
C) 21
D) an infinite number of times

E) B) and D)
F) All of the above

Correct Answer

verifed

verified

You may nest while and do-while loops but you may not nest for loops.

A) True
B) False

Correct Answer

verifed

verified

What will the following code display? int number = 6; number++; cout << number << endl;


A) 6
B) 5
C) 7
D) 0

E) All of the above
F) C) and D)

Correct Answer

verifed

verified

In a for statement, this expression is executed only once:


A) the test
B) null
C) initialization
D) validation
E) None of these

F) C) and D)
G) A) and B)

Correct Answer

verifed

verified

A special value that marks the end of a list of values is a


A) constant
B) counter
C) variable
D) sentinel
E) None of these

F) A) and C)
G) C) and D)

Correct Answer

verifed

verified

These are operators that add and subtract one from their operands.


A) plus and minus
B) ++ and --
C) binary and unary
D) conditional and relational
E) binary and ternary

F) A) and E)
G) A) and D)

Correct Answer

verifed

verified

The two important parts of a while loop are the expression that is tested for a true or False value and


A) a statement or block that is repeated as long as the expression is true
B) a statement or block that is repeated only if the expression is False
C) one line of code that is repeated once, if the expression is true
D) a statement or block that is repeated once, if the expression is true

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?


A) write(outFile, number) ;
B) outFile >> number;
C) outFile << number;
D) number >> outFile;

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

It is possible to define a file stream object and open a file in one statement.

A) True
B) False

Correct Answer

verifed

verified

If you want to stop a loop before it goes through all of its iterations, the break statement may be used.

A) True
B) False

Correct Answer

verifed

verified

The __________ loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.


A) while
B) for
C) switch
D) do-while
E) pre-test

F) A) and C)
G) A) and B)

Correct Answer

verifed

verified

Showing 21 - 40 of 60

Related Exams

Show Answer