COSC-1337 Chapter 5 Flashcards

1
Q

What is the first line of a while loop called?

while(condition) {

}

A

Loop header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Each execution of a loop is known as an?:

A

Iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a variable that controls the number of times a loop iterates called?

A

Loop control variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What type of loop is the while loop?

A

It is a “pre-test loop” this is because the condition is tested BEFORE each iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the “first read” called right before the input is tested by a while loop for input validation?

A

Priming read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The “++” and “–” operators can only work on what types of values/data?

A

They can only work with “lvalues” AKA a variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a “counter”?

A

It is a variable that increments each time a loop iterates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a “sentinel”?

A

It is a special value or character that is used to mark the end of a list of values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What type of loop terminates when the sentinel is entered?

A

A “sentinel-controlled loop”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What type of loop is the “do-while loop”?

A

It is a post-test loop. This means that AFTER each iteration the condition is then tested.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What file header must you include to use “toupper()” and “tolower()”?

A

cctype

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What type of loop is the “for loop”?

A

It is a pretest loop THAT IS COUNT CONTROLLED

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a loop inside of another loop called?

A

A “nested loop”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the name for saving data to a file called?

A

“Writing data” to a file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the name of a file that data is “written” to?

A

Output file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the process of retrieving data from a file called?

A

Reading data

17
Q

What term is used to describe the file that data is input from?

A

Input file. It is called this because a program is getting input from this file

18
Q

What are the two general types of files?

A

Text and binary files

19
Q

What is another name for “direct access file”?

A

Random access file

20
Q

How are files on a disk identified?

A

By their “filename”

21
Q

What is a file stream object?

A

It is an OBJECT that is associated with a SPECIFIC file on the computer’s disk. This object is created in a program in order for the program to be able to work with the file.

22
Q

Why does “file stream object” have the word “stream” in it?

A

Because it enables streams of data to be copied to memory from a file, and from a file to memory.

23
Q

What type of operations can we perform on a file object of the data type?

A

We can open the file and read its contents

24
Q

What type of operations can we perform on a file object of the data type?

A

We can create a file and write and save data to it.

25
Q

Are a programs files automatically shutdown when the program is terminated?

A

Yes. But it is a good practice to write out the close file statements within a program.

26
Q

Why should we write close file statements in our program?

A

So that the data in the “file buffer” is saved to our file.

Because some operating systems limit the number of files you can have open at one time. (Don’t deplete the computer’s resources on unnecessary files)

27
Q

What is the special value that the file stream object withholds as it’s reading data from a file?

A

Read position

28
Q

How do we read a value from a file stream object?

A

filestreamObject&raquo_space; readVaraible

29
Q

How do we declare a fstream file stream object that is named inputFile? How do we “link” the file customers.txt to it as well?

A

fstream inputFile;
inputFile.open(“customers.txt”);

OR

fstream inputFile(“customers.txt”);