CS Test 2

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

opened

A file must be ________ before data can be written to or read from it.

initialization, test, update

A for statement contains three expressions, what are they?

True

An initialization expression may be omitted from the for loop if no initialization is required.

closes a file

Assuming dataFile is a file stream object, the statement dataFile.close();

false

Function protoypes are required in the language.

True

Multiple relational expressions cannot be placed into the test condition of a for loop.

scope

The ________ of a variable is limited to the block in which it is declared.

post-test

The do-while loop is a ________ loop that is ideal in situations where you always want the loop to iterate at least once.

cstdlib, 1

The exit() function requires which library and how many parameters does it take?

False

The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.

True

The update expression of a for loop can contain more than one statement, e.g. counter++, total+= sales.

flag

This is a variable, usually a boolean or an integer, that signals when a condition exists.

&&

This operator represents the logical AND.

!

This operator takes an operand and reverses its truth or falsehood.

fstream

To allow file access in a program, you must #include this header file.

ifstream

To read data from a file, you define an object of this data type.

ofstream

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

the system will create an empty file of the specified name, there won't be an error

What will happen is a program attempts to open a file for writing and it does not exist?

zero

When a relational expression is false, it has the value ________.

<fstream>

Which header file should be included to allow file access in a program?

break

Without this statement appearing in a switch construct, the program "falls through" all of the statements below the one with the matching case expression.

variable

You may define a ________ in the initialization expression of a for loop.

outFile << number;

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?

assignment

In C++ the = operator indicates:


Set pelajaran terkait

Intro to Psychology- Module 2 Chapter 1: A Science Evolves: The Past, the Present, and the Future

View Set

Abnormal Psych Exam 1: Chapters 1-3, 5 & 6

View Set