1/28
Flashcards covering fundamental concepts from Chapter 2 including program structure, identifiers, built-in data types, arithmetic operations, operator precedence, memory allocation, and problem-solving steps.
What is a modular program in C++?
A program consisting of interrelated segments (or modules) arranged in a logical and understandable form, which can be implemented as classes or functions.
How does a function process input in C++?
A function accepts an input, processes the input, and produces an output, with its processing encapsulated and hidden inside the function.
What rules govern the naming of identifiers in C++?
The first character must be a letter or underscore; subsequent characters may only be letters, digits, or underscores; keywords cannot be used; and the maximum length is 1024 characters.
What is the function of main() in a C++ program?
The main() function serves as the driver function, directing the overall program execution and calling all other functions.
What three elements are contained in a C++ function header line?
The type of data returned by the function (if any), the name of the function, and the type of data passed into the function (argument list) when invoked.
What is the role of the return 0 statement in the main() function?
It returns a value of 0 from the function and causes the main program execution to end.
What is the cout object in C++?
It is an output object that sends data to a standard output display device.
What is a C++ preprocessor command and how is it formatted?
It is an instruction starting with a # symbol (such as #include
What is a string delimiter in C++?
A symbol, such as double quotes, that marks the beginning and end of a string literal without being part of the string itself.
How do single-line comments differ from block comments in C++?
Line comments begin with // and continue to the end of the line, whereas block comments begin with /* and end with */, spanning across multiple lines.
What are the two fundamental groupings of C++ data types?
Class data types (created by the programmer) and built-in data types (primitive types inherent to the compiler).
What are the nine built-in integer data types in C++?
bool, char, short int, int, long int, unsigned char, unsigned short int, unsigned int, and unsigned long int.
What ASCII code and storage size represent the letter 'A' in memory?
The ASCII code is 01000001, which takes 1byte of memory storage.
What information does the sizeof() operator return in C++?
It provides the number of bytes used by the compiler to store values of a specified data type or variable.
What is the difference between signed and unsigned integer data types?
Signed types permit negative, positive, and zero values. Unsigned types permit only positive and zero values, providing essentially double the positive range of their signed counterparts.
What are the storage sizes and value ranges for short int and unsigned short int?
short int uses 2bytes with a range of −32,768 to +32,767. unsigned short int uses 2bytes with a range of 0 to 65,535.
What are the storage sizes and value ranges for 4-byte int and unsigned int?
int uses 4bytes with a range of −2,147,483,648 to +2,147,483,647. unsigned int uses 4bytes with a range of 0 to 4,294,967,295.
What are the storage sizes and precision levels for C++ floating-point data types?
float uses 4bytes (single precision), while double and long double use 8bytes (double precision).
How do floating-point literals differ for float and long double types in code?
Floating-point literals are double by default. Appending an f or F creates a float literal (e.g., 9.234F), and appending an l or L creates a long double literal (e.g., 9.234L).
How does integer division differ from modulus division in C++?
Integer division (/) drops or truncates any fractional remainder (e.g., 15/2=7), whereas modulus division (%) yields only the integer remainder (e.g., 9%4=1).
What is a mixed-mode expression in C++ and what type of value does it return?
An expression containing both integer and floating-point operands, which yields a double-precision floating-point value.
What is operator associativity in C++?
The order in which operators of the same precedence level are evaluated in an expression (such as left-to-right or right-to-left).
What distinction exists between a variable declaration statement and a definition statement?
A declaration statement specifies the data type and identifier of a variable, while a definition statement causes the computer to allocate memory storage for it.
What is the purpose of the C++ address operator (&)?
It provides the memory address assigned to a specific variable.
What are the four steps in the problem-solving procedure for software development?
Step 1: Analyze the Problem; Step 2: Develop a Solution; Step 3: Code the Solution; Step 4: Test and Correct the Program.

According to the structure diagram of the main() function, what are the key labeled components?
The type of returned value (int), the function name (main), an empty argument list (), and the function body inside braces containing statements and return 0;.

Which integer data types are categorized in C++ as shown in Figure 2.6?
bool, char, short int, int, long int, unsigned char, unsigned short int, unsigned int, and unsigned long int.

How is the word 'BARTER' stored in memory as illustrated in Figure 2.7?
It uses 6bytes of storage, with each character stored in ASCII binary: B (01000010), A (01000001), R (01010010), T (01010100), E (01000101), and R (01010010).

What precedence levels and associativity are assigned to C++ arithmetic operators in Table 2.8?
Unary negation (-) has Right to left associativity; multiplication (*), division (/), and modulus (%) have Left to right associativity; addition (+) and subtraction (-) have Left to right associativity.