C++ CH4
text
A _____ file contains data that has been encoded as text, using a scheme such as ASCII or unicode.
binary
A _____ file contains data that has not been converted to text.
file buffer
A _____ is a small holding section of memory that file-bound data is first written to.
file stream object
A _____ is an object that is associated with a specific file and provides a way for the program to work with that file.
relational expression
A _____ is used to determine whether x is greater than y.
conditional
A _____ loop executes as long as a particular condition exists.
count controlled
A _____ loop is a loop that repeats a specific number of times.
note
A branch occurs when one part of a program causes another part to execute.
sequence structure
A type of program structure where the statements are executed in sequence, without branching off in another direction.
decision structure
In a _____, a specific action is taken only when a specific condition exists.
boolean expression
Relational expressions are also known as _____. Value can only be true or false.
&&
The _____ operator is known as the logical AND operator. it takes two expressions as operands and creates an expression that is true only when both sub-expressions are true.
||
The _____ operator is known as the logical OR operator. It takes two expressions as operands and creates an expression that is true when either of the sub-expressions are true.
note
The for loop. The for loop is a pretest loop that has built-in expressions for initializing, testing, and updating. These expressions make it very convenient to use a counter variable to control the number of iterations that the loop performs. The initialization expression can initialize the counter variable to a starting value, the test expression can test the counter variable to determine whether it holds the maximum value, and the update expression can increment the counter variable. {{{The for loop is ideal in situations where the exact number of iterations is known.}}}
priming read
The read operation that takes place just before the loop is called a _____. It provides the first value for the loop to test.
read position
When a file has been opened for input, the file stream object internally maintains a special value known as a _____.
filename extensions
_____ are short sequences of characters that appear at the end of a filename preceded by a period.
fstream
_____ file stream. Objects of this data type can be used to open files for reading, writing, or both.
ifstream
_____ is the input file stream. You can create an object of this data type when you want to open an existing file and read data from it.
ofstream
_____ is the output file stream. You can create an object of this data type when you want to create a file and write data to it.
input validation
_____ is the process of inspecting data given to a program by the user and determining if it is valid.
sentinel
a _____ is a special value that marks the end of a list of values.
concept.
concept. A counter is a variable that is regularly incremented or decremented each time a loop iterates.
concept
concept. A flag is a boolean or integer variable that signals when a conditions exists.
concept
concept. A loop that is inside another loop is called a nested loop.
concept.
concept. A running total is a sum of numbers that accumulates with each iteration of a loop. The variable used to keep the running total is called an accumulator.
concept
concept. Although most repetitive algorithms can be written with any of the three types of loops, each works best in different situations.
concept.
concept. As long as the user of a program enters bad input, the program will produce bad output. Programs should filter bad output.
concept.
concept. Logical operators are effective for determining whether a number is in or out of a range. && for within a range. || for out of a range.
concept.
concept. Logical operators connect two or more relational expressions into one or reverse the logic of an expression.
concept
concept. Relational operators allow you to compare numeric and char values and determine whether one is greater than, less than, equal to, or not equal to another.
concept.
concept. Relational operators can also be used to compare characters and string objects.
concept.
concept. The break statement causes a loop to terminate early. The continue statement causes a loop to stop its current iteration and begin the next one.
concept.
concept. The do-while loop is a posttest loop, which means its expression is tested after each iteration.
concept.
concept. The for loop is ideal for performing a known number of iterations.
concept
concept. The if statement can cause other statements to execute only under certain conditions.
concept
concept. The if statement can conditionally execute a block of statements enclosed in braces.
concept.
concept. The if/else if statement tests a series of conditions. It is often simpler to test a series of conditions with the if/else if statement than a set of nested if/else statements.
concept
concept. The if/else statement will execute one group of statements if the expression is true, or another group of statements if the expression is false.
concept.
concept. The switch statement lets the value of a variable or expression determine where the program will branch.
concept
concept. To test more than one condition, an if statement can be nested inside another if statement.
concept.
concept. When a program needs to save data for later use, it writes the data in a file. The data can then be read from the file at a later time.
concept.
concept. You can use nested if/else statements or the if/else if statement to create menu-driven programs. A menu-driven program allows the user to determine the course of action by selecting it from a list of actions.
concept.
concept. You can use the conditional operator to create short expressions that work like if/else statements.
concept.
concept. the while loop can be used to create input routines that repeat until acceptable data is entered.
note.
note. A count controlled loop must possess three elements. 1. It must initialize a counter variable to a starting value. 2. it must test the counter variable by comparing it to a maximum value. When the counter variable reaches its maximum value, the loop terminates. 3. It must update the counter variable during each iteration, usually by incrementing.
note.
note. A file's read position marks the location of the next byte that will be read from the file.
note
note. Precedence and Associativity of Logical operators. in order of precedence ! && ||
note
note. The do-while loop is a good choice for repeating a menu.
note
note. The do-while loop. The do-while loop is also a conditional loop. Unlike the while loop, however, do-while is a posttest loop. It is ideal in situations where you always want the loop to iterate at least once. The do-while loop is a good choice for repeating a menu.
note.
note. The while loop. a conditional loop, which means it repeats as long as a particular condition exists. It is also a pretest loop, so it is ideal in situations where yo do not want the loop to iterate if the condition is false from the beginning. For example, validating input that has been read and reading lists of data terminated by a sentinel value are good applications of the while loop.
note.
note. You should use the do-while loop when you want to make sure the loop executes at least once.
note.
note. You should use the for loop instead of the while or do-while loop in any situation that clearly requires an initialization, uses a false condition to stop the loop, and requires an update to occur at the end of each loop iteration.
note.
note. do-while block do { statement; statement; } while (expression);
note.
note. for loop format. for (initialization; test; update) statement;
note
note. general format of a do-while loop. do statement; while (expression);
note.
note. the do-while loop must be terminated with a semicolon.
note
note. the for loop is a count controlled loop. it is a pretest loop as well.
note.
note. the fstream header file contains all the declarations necessary for file operations.
note
note. the switch statement is a natural mechanism for building menu systems.
note.
note. this is how to check if a file opened successfully. if (inputFile.fail())
note.
note. you can both define and initialize the counter variable in the loop header.
note.
note. you can omit a for loop's initialization expression if it is defined beforehand. int num = 1; for ( ; num <= maxValue; num++) etc.
!
the _____ operator performs a logical NOT operation. It takes an operand and reverses its truth or falsehood. In other words, if the expression is true, the _____ operator returns false, and if the expression is false, it returns true.
posttest
the do-while loop is a _____ loop?
warning
warning. Break and continue mess with the normal conditions of loops, they should mostly be avoided.
random access
when you work with a _____ file (also known as a direct access file), you can jump directly to any piece of data in the file without reading the data before it.
sequential access
when you work with a _____ file, you access data from the beginning of the file to the end of the file.