Chapter 5 - Loops and Files Flashcards

1
Q

Define: nested loop

A

A loop that is inside another loop

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

The fill member function of cout changes the fill character which is a _____ by default.

A

The fill member function of cout changes the fill character which is a SPACE by default.

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

If you use:
cout.fill(‘0’);
the fill function will cause a ___ to be printed in front of all single digit numbers.

A

ZERO

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

An inner loop goes through ___ of its iterations for EACH iteration of an outer loop.

A

ALL

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

Inner loops complete their iterations (faster/slower) than outer loops.

A

FASTER

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

To get the total number of iterations of a nested loops, multiply ….

A

the number of iterations of ALL loops.

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

Define writing data

A

process of saving data to the file

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

When a piece of data is written to a file, it is copied from a _______ in ______ to the ______.

A

When a piece of data is written to a file, it is copied from a VARIABLE in RAM to the FILE.

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

Define reading data

A

process of RETRIEVING data from a file

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

When a piece of data is READ from a file, it is copied from the _____ into a _____ in _____.

A

When a piece of data is read from a file it is copied from the FILE into a VARIABLE in RAM.

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

input file

A

file from which data is read

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

Input file is called an input file because the program gets ____ from the ____.

A

gets INPUT from the FILE.

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

When a file is used by a program, what 3 steps must be taken?

A

1) Open the file (connect the file to the program)
2) Process the file (data written/read to file)
3) Close the file (disconnect the file from the program)

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

What are the 2 types of files?

A

1) Text

2) Binary

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

File Access Methods - what are the 2 general ways to access data?

A

1) sequential-access file (like a tape)

2) random-access file (also known as direct access file) - like a CD

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

In order for a program to work with a file on the computer’s disk, the program must create a ____ _____ _____ in memory

A

file stream object

17
Q

ofstream

A

output file stream

when you want to create a file and write data to it

18
Q

ifstream

A

input file system

when you want to open an existing file and read data from it

19
Q

fstream

A

file stream

can be used to open files for reading, writing or both