A computer program consists of step-by-step instructions to the computer from a computer programmer.
A programming language is a language that resembles the structure and syntax of human language, and that is used by computer programmers to write instructions for computers.
A function is a group of related instructions, also called statements, which together perform a particular task.
A C++ program must have one main function, no more, no less.
A standard library file is a file that defines commonly used objects, such as cout.
The purpose of an include directive is to tell the program to include a particular standard library file in your application.
A preprocessor is a program that scans the source code for include directives, and then inserts them into the source code of all files included by the include directives.
The compiler is a program that translates the preprocessed source code (the source code after the insertions made by the preprocessor) into corresponding machine language instructions that are stored in an object file.
The linker is a program that combines the object file with the necessary parts of the run-time library and creates an executable file.
Persistent storage is not temporary like the other two: cache memory and RAM.
One byte of information may be stored at a particular memory address.
No. The size of a data type may vary depending on the compiler and operating system.
The value of an unsigned data type is either zero or positive, never negative, while the value of a signed data type may be negative also.
An ASCII value is a number between 0 and 255 that corresponds to a particular character.
A literal string is a string, generally encased in double quotes, that is outputted literally, without evaluation.
An expression is a code statement with a value that has to be evaluated when the program runs.
Declaring a variable reserves memory for the storage of information and provides a name by which that information later can be referred to in code.
No. An undeclared identifier compiler error will occur even though the variable is declared after it is referred to because the compiler reads the code from top to bottom, so when it reaches the first reference to the variable, it has not yet seen the variable declaration.
The address operator is used to obtain the hexadecimal value of a variables memory address, whereas the sizeof operator is used to determine the number of bytes in memory required to store the variable on the compiler and operating system where the program is running.
Initialization is when you assign a value to a variable in the same statement in which you declare that variable. By contrast, assignment is when you assign a value to a variable in a statement after the one in which you declare that variable.
Overflow occurs when a variable is assigned a value too large for its range.
You use the cin object for run-time assignment of values to variables .
Division has more than one operator, / and %.
The modulus operator cannot have a floating-point operand.
The two division operators, / and %, cannot have zero as a second operand.
total + = 5
The result of 4 + 3 * 2 is 10, not 14, because multiplication has precedence over addition.
The result of the expression 8 / 2 * 4 is 16, not 1, because of associativity. Multiplication and division have equal precedence, so the operations are performed from left to right.
The result of the expression 15 / 4 is 3, not 3.75, because of integer division.
C++, unlike some other programming languages, does not have an exponent operator. Instead, you use the pow function, defined in the cmath standard library, to raise a number to a certain power.
An algorithm is a step-by-step logical procedure for solving a problem.
There are two operands in a relational expression.
The data type of the expression following the if keyword is Boolean.
In an if / else if / else statement, you must have one, but only one, if part.
In an if / else if / else statement, you may have more than one else if part.
In an if / else if / else statement, you may omit the else part, in which case the statement becomes an if / else if statement.
In a switch statement, the required data type of expression following the switch keyword is integer.
In a switch statement, the expression following a case keyword must be a constant or a literal and therefore cannot be a variable.
The default keyword in a switch statement corresponds to the else keyword in an if / else if / else statement.
You can use nested if statements as an alternative to the logical And and Or operators.
With the logical And operator, both Boolean expressions have to be true for the overall Boolean expression to be true.
With the logical Or operator, both Boolean expressions have to be false for the overall Boolean expression to be false.
The logical Not operator reverses the truth of a Boolean expression, making a true expression false and a false expression true.
The increment operator increases a value by one.
The decrement operator decreases a value by one.
In the statement cout << --num, decrementing num occurs before the outputting of the value of num because the decrementing is a prefix.
An iteration is each time a loop repeats.
The usual purpose of the first expression in the parentheses following the for keyword is to initialize a variable which usually serves as the counter.
The purpose of the second expression in the parentheses following the for keyword is to set the condition which must be true for the loop to continue to execute.
The usual purpose of the third expression in the parentheses following the for keyword is to update a value, usually a counter.
One or more of the expressions in the parentheses following the for keyword may be empty if handled elsewhere in the code.
The purpose of the break keyword in a for loop is to prematurely terminate the loop.
The purpose of the continue keyword in a for loop is to prematurely terminate the iteration of a loop.
If you were going to use nested for loops to print rows and columns, you would use the inner for loop to print the columns .
The do while loop executes at least once.
The for loop is the best choice when the number of iterations is predictable.
The parenthetical expression following the while keyword is for the condition.
A flag is a Boolean variable whose value indicates whether a condition exists.
A variables scope determines where it can be referred to in the code. A variables lifetime determines when it is destroyed .
No. A function other than main does not have to be prototyped if it is defined above where it is called. However, it is a good idea to prototype each function other than main.
No. A function need not have any arguments. If it has none, then the void keyword may be used in the parentheses following the function name.
Yes. A function may have more than one argument. If so, the arguments are separated by commas.
If a variable in main is passed by value to another function that changes the argument corresponding to that variable, the variable in main is not changed.
If a variable in main is passed by reference to another function that changes the argument corresponding to that variable, the variable in main is changed.
No. A function does not have to have a return value. If it doesnt have a return value, the keyword void is used in its place.
No. A function may not have more than one return value.
Yes. A function does not have to have a return value nor any arguments.
Yes. A function may have both a return value and arguments.
While the data type of an array may be integer, float, or character, a particular array cannot contain integers, floats, and characters . All the elements of an array must be of the same data type.
The number of the starting index of an array is zero.
The number of the ending index of an array is one less than the number of elements in the array.
The two alternative methods of initializing an array are explicit initialization, in which the square brackets contain a numerical constant indicating the size of the array, or implicit initialization, in which the square brackets are empty and the size of the array is indicated by the number of elements on the right side of the assignment operator.
The purpose of the null character is to signal cout when to end the output of a character array.
The value of the name of an array is the base address of the array.
When you pass an array name as a function argument, you are passing it by address.
A pointer is a variable or constant whose value is the address of another variable or constant.
The only difference between declaring an integer variable and an integer pointer variable is that the pointer variable declaration includes an asterisk, which either follows the data type or precedes the variable name.
The data type in the declaration of a pointer refers to the data type of another variable (or constant) whose memory address is the value of the pointer.
NULL is a constant defined in several standard libraries, including iostream . You assign a pointer NULL if it is too early in your code to know which address to assign to the pointer. The value of NULL, the memory address 0, signals that the pointer is not intended to point to an accessible memory location.
You use the address operator to assign a pointer the address of another variable or constant.
The purpose of the indirection operator is to obtain the value of the variable or constant to which the pointer points. This operation is said to dereference the pointer.
Incrementing a pointer variable increases its value by the number of bytes of its data type.
The purpose of the new operator is to dynamically allocate memory at run-time. The purpose of the delete operator is to deallocate dynamically created memory.
You cannot use an assignment operator to assign the value of one C-string to another. You will be assigning an address instead of a value.
Data is persistent when it survives after the program is finished.
A file is a collection of data that is located on persistent storage, such as a hard drive, a CD-ROM, or other storage device.
You should include the fstream standard library when your program reads from, or writes to, files.
The fstream object may be used both for file input and file output.
You can open a file with either the open member function or a constructor.
The purpose of opening a file is to establish a path of communication between the file and a file stream object in your program.
The purpose of closing a file is to free system resources that are required to maintain the path of communication between the file and the file stream object in your program.
A constructor is a function that is automatically called when you attempt to create an instance of an object.
File stream objects should be passed as function arguments by reference rather than by value.
An is a relationship is involved in inheritance. An example is a student is a person.
A has a relationship is involved in containership. Examples include that a car has an engine and a person has a birthday.
A structure is a programmer-defined data type that enables you to package related variables that may be of different data types.
You may initialize a structure using either an initialization list or a constructor.
You can nest one structure within another structure, such as a birthday member variable of a Person structure being a Date structure itself.
A structure may be passed by reference even if the function will not change the value of its member variables because less memory is required to pass the address of an object than the object itself, which may take up a lot of bytes. In this situation, you may precede the structure instance in the function argument list with the const keyword to prevent the function from inadvertently changing the values inside the structure instance.
Member variables are, by default, public in a structure but private in a class.