1/23
Flashcards covering fundamental topics in C++ programming including algorithms, control structures, data types, operators, and execution steps.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is an algorithm?
A step-by-step list of instructions to solve a problem that is clear, finite, ordered, and gives a correct output.
What is pseudocode?
An algorithm written in plain English that looks like code. It is not real code, has no strict syntax rules, and cannot be run.
What are the four primary flowchart shapes and their meanings?
Oval means Start / End, Parallelogram means Input / Output, Rectangle means Process (calculation), and Diamond means Decision (yes/no).
What are the three control structures used by every algorithm?
Sequence (steps run one after another), Selection (choose a path with if/else), and Repetition (repeat steps using loops).
Who created C++, and what is its origin?
C++ was created by Bjarne Stroustrup as an extension of the C programming language.
What is the function of a compiler in C++?
A compiler translates source code (saved as .cpp) into machine language (0s and 1s).
What is a preprocessor directive in C++?
Lines starting with # (such as #include
What is the main function in C++?
The starting point of every C++ program where execution always begins, written as int main() and returning 0 upon successful completion.
What are the four main pillars of Object-Oriented Programming (OOP)?
Encapsulation, Inheritance, Polymorphism, and Abstraction.
What are the key differences between Structured Programming and Object-Oriented Programming?
Structured focuses on functions, uses a top-down approach, and has separate data with less security. OOP focuses on objects, uses a bottom-up approach, bundles data with functions in classes, and provides data hiding (encapsulation) and high reuse.
What rules must C++ identifiers follow?
They can contain only letters, digits, and underscores; cannot start with a digit; cannot contain spaces or special symbols; cannot be keywords; and are case-sensitive.
What is the difference between char and string literals in C++?
char represents a single character enclosed in single quotes (e.g., 'A'), whereas string represents a group of characters enclosed in double quotes (e.g., "A").
What are the typical sizes and data types used in C++?
int (4 bytes) for whole numbers, float (4 bytes) for decimals, double (8 bytes) for precise decimals, char (1 byte) for one character, bool (1 byte) for true/false, string (varies) for text, and void for no value.
What is the difference between variable declaration and initialization?
Declaration tells the compiler the variable's data type and name (e.g., int age;). Initialization gives the variable its first value (e.g., int age = 18;).
How do pre-increment (++x) and post-increment (x++) operations differ?
Pre-increment (++x) adds 1 to the variable first and then uses the new value. Post-increment (x++) uses the current value first and then adds 1 to the variable.
How does integer division behave in C++ compared to floating-point division?
Integer division drops the decimal part (e.g., 7/2=3). For a decimal result, at least one operand must be a double or float (e.g., 7.0/2=3.5).
What is the difference between the '=' and '==' operators?
The '=' symbol is an assignment operator used to store a value in a variable, while '==' is a relational operator used to compare two values.
What is the operator precedence order from highest to lowest in C++?
How is the mathematical expression 2a+b written as a valid C++ expression?
(a + b) / 2
What is the hierarchy of implicit type conversion (promotion) in mixed expressions?
char -> int -> float -> double
What is a requirement when declaring a constant using the 'const' keyword?
A const variable must be initialized with a value at the time it is declared, and its value cannot be changed later.
Which operators are used with standard input (cin) and standard output (cout)?
cout uses the insertion operator (<
What are the five steps to create a C++ program?
What are the three types of programming errors in C++?