SECTION 1: Recap of C, C++ & Reference Type Flashcards
(10 cards)
What is the programming paradigm of the C language?
Procedural / Structural. It breaks programs into smaller modules to reduce complexity.
What memory functions does C use for dynamic memory allocation and deallocation?
Allocation: malloc() and calloc()
Deallocation: free()
Does C support inline functions or function overloading?
No, C does not support inline functions, function overloading, or function overriding.
Does C have access specifiers like public and private?
No. C does not support access specifiers.
What are macros in C, and what is _Generic() used for?
define INC(x) _Generic((x), long double: INCl, default: INC, float: INCf)(x)
Macros: Preprocessor replacements like #define PI 3.14
_Generic(): Used in C11 for type-specific macros, e.g.:
What is a reference variable in C++?
It’s an alias for another variable. Must be initialized. Syntax:
Example .
int x = 10;
int& ref = x; // now ref behaves like x
Can reference variables in C++ be reseated to another variable?
No. Once bound to a variable, a reference cannot be changed to refer to another.
Explain “call by reference” using a reference variable.
Function receives an alias (reference) to the variable. Changes inside function reflect outside:
void modify(int& x) { x += 5; }
int a = 10; modify(a); // a becomes 15
What are the four stages in C++ compilation?
Preprocessor (#include, #define, comment removal)
Compiler (generates object code)
Linker (resolves addresses and combines files)
Executable (.exe file is produced)