1/86
Comprehensive vocabulary flashcards covering decision-making structures, loops, functions, and scoping rules in C++.
ASCII (American Standard Code for Information Interchange)
A character encoding standard that converts characters into numeric binary codes, supporting 128 characters in C++, including uppercase letters (65 through 90), lowercase letters (97 through 122), numeric characters (48 through 57), and the null character (0).
Relational Operators
Operators (>, <, >=, <=, ==, !=) used to compare numeric and character values to determine their relative order, producing a Boolean result of true (1) or false (0).
Flag
A variable, typically defined as a bool or an int, that signals whether a specific condition currently exists in a program, where 0 represents false and any non-zero value represents true.
Trailing else
The final else clause in an if/else if sequence that provides a default action when none of the preceding relational conditions evaluate to true.
Short-Circuit Evaluation
The evaluation rule where the second operand of a logical operator (&& or ∣∣) is skipped if the first operand is sufficient to determine the truth value of the entire expression.
Block Scope
The lifetime and visibility of a variable defined inside braces ({}), extending strictly from its point of definition to the closing brace of that block.
cctype Functions
A C++ character classification library providing functions such as isalpha, isdigit, islower, isupper, isspace, isalnum, isprint, and ispunct to test the category of a character.
Conditional Operator
A ternary operator formatted as ?: that evaluates a condition and returns the value of one of two subexpressions depending on whether the condition evaluates to true or false.
switch Statement
A multi-way branching statement that compares an integer or character expression against multiple constant case labels to determine which group of statements to execute.
break Statement
A control statement used to terminate execution in a switch structure to prevent fall-through, or to terminate and exit early from the body of a loop.
Pretest Loop
A loop structure, such as a while loop or for loop, that tests its controlling expression prior to executing the body; if initially false, the loop body executes 0 times.
Post-test Loop
A loop structure, specifically the do-while loop, that evaluates its condition after the body executes, guaranteeing that the body executes at least 1 time.
Counter
A variable incremented or decremented on each iteration of a loop, typically initialized prior to the loop and used to control repetition.
Sentinel
A special terminal value in an input sequence that signals the end of input data and cannot be mistaken for valid input (such as −1 or −999).
Infinite Loop
A loop that fails to exit because its condition never evaluates to false, often caused by omitting the increment or update step inside the loop body.
Nested Loop
A loop placed entirely inside the body of an outer loop, where the inner loop executes all of its iterations for every single iteration of the outer loop.
continue Statement
A control statement that halts the current loop iteration and jumps immediately to the update step in a for loop or the condition evaluation in a while or do-while loop.
Modular Programming
A software design technique that divides a program into smaller, manageable functions to simplify coding and improve program maintainability.
Function Prototype
A declaration placed before function calls that notifies the compiler of the function name, return type, and parameter data types, terminated by a semicolon.
Function Header
The initial line of a function definition that specifies the return type, the function name, and the parameter list with parameter names, containing no terminating semicolon.
Pass by Value
A parameter passing mechanism where a copy of an argument value is transferred into the parameter variable, protecting the original variable from modification.
Reference Variable
An alias for another variable defined with an ampersand (&); when used as a parameter, modifications made to it directly alter the original argument variable.
Static Local Variable
A local variable declared with the static keyword that is initialized only once during the initial function call and retains its value between subsequent calls.
Variable Shadowing
A condition where a local variable declared in an inner block or function has the same identifier as an outer or global variable, hiding the outer variable within that block.
Function Signature
The unique combination of a function's identifier name and the ordered sequence of its parameter types, excluding the return type.
Overloaded Functions
Two or more functions sharing the same name but having different signatures (parameter types or number of parameters), resolved by the compiler at the point of call.
Recursion
A process in which a function calls itself directly or indirectly to solve a problem until reaching a terminating base condition.
ASCII Character Encoding Scheme
A 7-bit character encoding system that maps individual characters to numeric codes spanning 0 through 127 (128 total characters supported in standard C++), where uppercase letters range from 65 through 90, lowercase letters range from 97 through 122, numeric digits range from 48 through 57, and the null character is represented by 0.
Relational Operator Hierarchy and Output
A group of comparison operators where relational order operators (>, >=, <, <=) hold higher precedence than equality operators (==, !=), all evaluating strictly to a Boolean result of true (1) or false (0).
Short-Circuit Evaluation in C++
A compiler evaluation rule where the right operand of a logical expression is skipped completely if the left operand is sufficient to determine the final truth value: if the first operand is false in an && expression, or true in a ∣∣ expression.
Code Output: Logical and Relational Precedence with cout << (2 < 3 || 5 > 6 && 7 > 8);
Outputs 1 because relational comparisons execute first, followed by logical AND (&&) due to higher precedence than logical OR (∣∣), simplifying the expression to (1∣∣0), which evaluates to true (1).
Conditional (Ternary) Operator Syntax and Function
A three-operand operator formatted as condition?expression1:expression2, which evaluates the condition and executes or returns the value of expression1 if true, or expression2 if false.
Code Output: Ternary Operator Evaluation with int age = 17; cout << (age >= 18 ? "Adult" : "Minor");
Prints Minor because the condition age>=18 evaluates to false (17>=18 is false), prompting the conditional operator to select the subexpression following the colon.
The switch Statement Execution and the break Keyword
A multi-way branching statement that compares an integral expression against constant case values, where the omission of a break statement results in fall-through, causing execution to continue sequentially through following cases regardless of their labels.
Code Output: switch Statement Fall-Through Trace
When grade = 'B' is evaluated in a switch block containing case 'B': cout << "Good"; without a break, followed immediately by case 'C': cout << "Average"; break;, it prints GoodAverage because control falls directly into the next case.
Fundamental Difference: Pretest Loops vs. Post-Test Loops
Pretest loops (such as while and for) evaluate their condition prior to entering the loop body and may execute 0 times, whereas post-test loops (do-while) evaluate the condition after body execution, guaranteeing at least 1 iteration.
Code Output: Postfix Increment Evaluation with int a = 2, b = 5; int c = a * b++;
Assigns 10 to variable c and updates b to 6, because postfix increment uses the current value of b (5) in the multiplication before incrementing b in memory.
Sentinel Value in Loop Control
A distinctive dummy value placed in an input sequence to signal the completion of data entry and terminate the loop, chosen specifically so it cannot be mistaken for valid input data (e.g., using −1 or −999 for non-negative scores).
Code Tracing: Nested Loop Execution Count for for(int i=0; i<3; i++) for(int j=0; j<2; j++) count++;
Increments count a total of 6 times, because the inner loop executes its full cycle of 2 iterations for every single one of the 3 iterations of the outer loop (3×2=6).
Control Flow Distinction: break vs. continue in Loops
The break statement terminates the innermost loop entirely and jumps to the code following the loop structure, whereas continue halts only the current iteration, jumping directly to the loop's update step (for) or condition test (while/do-while).
Architectural Distinction: Function Prototype vs. Function Header
A function prototype is a declaration ending with a semicolon placed before function calls to alert the compiler of the function's name, return type, and parameter types, whereas a function header is the first line of the actual function definition containing parameter names and no semicolon.
Parameter Passing Mechanisms: Pass by Value vs. Pass by Reference
Pass by value transfers an isolated copy of the argument into the parameter, preventing changes to the original variable, whereas pass by reference (using &) transfers an alias bound directly to the argument, allowing the function to modify the caller's variable.
Code Output: Pass by Reference with void test(int &x) { x += 5; } int main() { int n = 10; test(n); cout << n; }
Displays 15 because parameter x is declared as a reference variable (&x), causing modifications made to x inside test to directly alter the memory location of n in main.
Static Local Variable Behavior and Lifetime
A local variable declared with the static keyword that is initialized only once upon the first function invocation and retains its value between subsequent calls across the entire execution of the program.
Variable Shadowing in Nested Blocks and Functions
A condition occurring when a local variable declared inside an inner block or function shares the exact same name as an outer or global variable, rendering the outer variable inaccessible and hidden within the boundaries of that inner block.
Function Signature and Overloading Resolution
A function signature consists exclusively of the function name and the ordered data types in its parameter list (excluding the return type); overloaded functions share a name but feature distinct signatures, enabling the compiler to invoke the matching version.
Code Output: Static Local Variable Accumulation in Loops
Calling a function containing static int c = 0; c++; cout << c << " "; three times in a loop prints 1 2 3 because the static variable c preserves its incremented value between successive function calls rather than re-initializing.
ASCII Character Encoding Standard
A 7-bit character encoding standard that maps characters to numeric binary codes, supporting 128 discrete characters in C++ ranging from 0 to 127, where uppercase letters span 65 through 90, lowercase letters span 97 through 122, numeric digits span 48 through 57, and the null terminator is represented by 0.
Underlying Representation of char in C++
An 8-bit (1-byte) integer data type providing 256 total values (0 through 255) that follows standard integer rules and converts to visible characters by decoding numeric values via character sets like ASCII.
Relational Operators
Comparison operators (>, <, >=, <=, ==, !=) evaluated from left to right that determine the relative order or equality of two operands, strictly producing a Boolean integer result of true (1) or false (0).
Assignment Operator vs. Equality Operator
The single equals sign (=) assigns the evaluated value of the right-hand operand to the variable on the left, whereas the double equals sign (==) compares two expressions for equivalence without altering values, evaluating to true (1) or false (0).
Flag Variable
A variable, typically declared as a bool or an int, used to signal whether a specific condition currently exists in a program, where an evaluated value of 0 represents false and any non-zero value represents true.
Trailing else Clause
The final else statement in an if/else if sequence that provides a default action executed only when all preceding relational test conditions evaluate to false.
Short-Circuit Evaluation
An evaluation rule where the second operand of a logical expression is skipped completely if the first operand is sufficient to determine the overall truth value: when the first operand is false in an && expression, or true in a ∥∥ expression.
Logical Operator Precedence Hierarchy
The strict order of evaluation among logical operators where logical NOT (!) holds the highest precedence, followed by logical AND (&&), and finally logical OR (∥∥) with the lowest precedence.
Block Scope
The visibility and lifetime of an identifier defined within curly braces ({}), extending strictly from its point of declaration to the closing brace of that block, after which the identifier is destroyed.
Variable Shadowing
A scenario where a local variable declared in an inner block or function has the same identifier name as an outer or global variable, hiding the outer variable and making it inaccessible within that inner scope.
cctype Character Classification Functions
A C++ library providing functions such as isalpha, isdigit, islower, isupper, and isspace that test the character category of a char argument and return a non-zero integer for true or 0 for false.
Conditional (Ternary) Operator
A three-operand operator formatted as condition ? expression1 : expression2 that evaluates a Boolean condition and executes or returns the value of expression1 if true, or expression2 if false.
The switch Statement
A multi-way branching statement that compares the value of an integer or character expression against constant integral case labels to determine which group of statements to execute.
Fall-Through Behavior in switch Structures
The sequential execution of statements in subsequent case blocks that occurs when a matching case lacks a terminating break statement, continuing until a break or the end of the switch is reached.
Pretest Loops vs. Post-Test Loops
Pretest loops (while and for) evaluate their condition before the loop body executes and may run 0 times, whereas post-test loops (do-while) evaluate the condition after the body executes, guaranteeing at least 1 execution.
Increment and Decrement Operators: Prefix vs. Postfix Mode
Prefix mode (++var, --var) modifies the variable first and returns the updated value to the expression, while postfix mode (var++, var--) yields the current value to the expression before modifying the variable in memory.
Counter Variable
A variable incremented or decremented by a fixed value on each iteration of a loop, typically initialized prior to loop entry and used as a loop control variable to govern repetition.
Sentinel Value
A distinctive terminal value placed in an input sequence that signals the end of input data and terminates a loop, chosen specifically so that it cannot be confused with valid, legitimate data (such as −1 or −999).
Infinite Loop
A loop structure that continues executing indefinitely because its controlling test condition never evaluates to false, frequently caused by omitting the counter update step inside the loop body.
Nested Loops
A loop placed entirely inside the body of an outer loop, where the inner loop executes its complete set of iterations for every single iteration performed by the outer loop.
The break Statement vs. The continue Statement in Loops
The break statement terminates the innermost loop immediately and transfers control out of the loop, whereas continue skips the rest of the current iteration and jumps directly to the condition test or update step.
Modular Programming
A software design approach that divides a large program into smaller, manageable, and independent functions, simplifying code authoring, debugging, testing, and long-term maintenance.
Function Prototype vs. Function Header
A function prototype is a declaration ending with a semicolon placed before function calls to inform the compiler of the function's interface, whereas a function header is the first line of the actual function definition without a semicolon.
Pass by Value Mechanism
A parameter-passing mechanism where a copy of the argument value is passed into the function parameter, ensuring that any modifications made to the parameter do not affect the caller's original variable.
Pass by Reference Mechanism
A parameter-passing mechanism where an ampersand (&) declares a parameter as an alias for the argument variable, allowing the function to directly access and modify the variable in the calling environment.
Static Local Variable
A local variable declared with the static keyword that is initialized only once upon the first function invocation and retains its value between subsequent function calls throughout program execution.
Global Variable vs. Global Constant
A global variable is defined outside all functions and can be modified anywhere in the file (defaulting to 0 or null), whereas a global constant uses the const qualifier to create a read-only value accessible to all functions.
Function Signature and Function Overloading
A function signature consists of the function name and the ordered data types of its parameters (excluding the return type); function overloading allows multiple functions to share a name if their signatures differ.
Code Output: Logical Precedence in cout << (2 < 3 || 5 > 6 && 7 > 8);
Outputs 1 because relational operators evaluate first, simplifying to (1∥∥0&&0); then logical AND evaluates before logical OR, yielding (1∥∥0), which evaluates to true (1).
Code Output: Postfix Increment Multiplication with int a = 2, b = 5; int c = a * b++;
Assigns 10 to variable c and updates b to 6, because postfix increment evaluates the multiplication using b's current value (5) before incrementing b in memory.
Code Output: Nested Loop Iteration Count with for(int i = 0; i < 3; i++) for(int j = 0; j < 2; j++) count++;
Increments count a total of 6 times, because the inner loop executes its full cycle of 2 iterations for every single one of the 3 iterations of the outer loop (3×2=6).
Code Output: Switch Fall-Through with case 'B': cout << "Good";
Prints GoodAverage when grade = 'B' because case 'B' contains no terminating break statement, causing execution to fall through into case 'C': cout << "Average"; break;.
Code Output: Pass by Reference with void test(int &x) { x += 5; } int main() { int n = 10; test(n); cout << n; }
Displays 15 because parameter x is declared as a reference variable (&x), causing modifications made to x inside test to directly alter the memory location of n in main.
Code Output: Static Local Variable Accumulator with static int c = 0; c++; cout << c << " ";
Prints 1 2 3 when called three times in a loop because the static local variable c preserves its incremented value across successive function calls rather than re-initializing.
Code Output: While Loop Accumulator with int day = 1; while(day <= 3) { total += 10; day++; }
Results in total being incremented by 30 because the loop executes exactly 3 iterations (when day is 1, 2, and 3), adding 10 on each pass before terminating when day reaches 4.
Code Output: Character Arithmetic and Conversion with cout << static_cast<char>(65 + 2);
Displays C because in the ASCII encoding scheme, numeric code 65 corresponds to character 'A', so adding 2 evaluates to 67, which represents 'C' when cast to char.
Code Output: Short-Circuit Evaluation Side Effects with int x = 1, y = 0; if (x++ && y++) cout << x << y; else cout << y << x;
Displays 12 because x++ evaluates to 1 (true) and increments x to 2, prompting evaluation of y++ which evaluates to 0 (false) and increments y to 1; the else branch executes printing y (1) then x (2).
Code Output: Nested If Dangling Else Resolution with if (a > b) if (a > 0) cout << "X"; else cout << "Y"; else cout << "Z";
When a=2 and b=5, it outputs Z because the condition a > b (2>5) evaluates to false, causing execution to jump directly to the outer matching else branch.
Code Output: Prefix vs. Postfix Decrement with int a = 5; while (a-- > 0) cout << a;
Prints 43210 because a-- > 0 tests the current value of a before decrementing it, so on the first iteration it tests 5>0 (true) and prints the decremented value 4, continuing until testing 0>0 (false).
Code Output: Function Default Arguments with int add(int a, int b = 2, int c = 3) { return a + b + c; } cout << add(1);
Outputs 6 because passing only one argument assigns a=1, while parameters b and c utilize their default argument values of 2 and 3, summing to 1+2+3=6.