Programming and Software Development
This shared-core programming guide covers language constructs, object-oriented design, development processes, and testing. Practice reading and debugging code: predict output, identify a scope or logic error, and choose tests that expose faults. These are independent exercises rather than a claim about a particular examination’s question distribution.
Constructs and control flow
Variables have type, scope, and lifetime. Local variables exist inside a block or function; parameters receive arguments; global variables are visible more broadly and increase coupling. Value parameters copy the argument; reference parameters can modify the caller's object. Control flow uses sequence, selection, and iteration. Recursion needs a base case and progress toward it; each call adds a stack frame. Short-circuit evaluation means A AND B skips B when A is false; A OR B skips B when A is true.
OOP and process
Encapsulation hides internal state behind methods; inheritance extends a class; polymorphism lets one interface dispatch to different implementations. Overloading is same-name methods with different signatures; overriding replaces an inherited method. The SDLC includes requirements, design, implementation, testing, deployment, and maintenance. Unit tests isolate small units, integration tests combine them, system tests check the whole product, and acceptance tests check user needs. Regression tests confirm changes did not break existing behavior. Version control tracks changes and enables branching and merging.
Worked example
Trace function f(n): if n <= 1 return 1; otherwise return n * f(n-1). f(4) = 4 * f(3) = 4 * 3 * f(2) = 4 * 3 * 2 * f(1) = 24. The base case stops recursion; without it the calls continue until stack overflow. The function computes factorial, and its running time is O(n) calls with O(n) stack depth.
Concrete C++ practice with explicit assumptions
For a fragment using the standard input and output streams, distinguish extraction in std::cin >> x from insertion in std::cout << x. State that input succeeds before tracing a value. Follow a loop in a table showing its initialization, condition, body and update; do not count an iteration whose condition fails. A condition using == compares values, whereas = assigns a value. Check the intended expression before interpreting its result.
Keep language-specific operations separate from pseudocode. With ordinary positive integer operands, 7 / 2 produces the integer quotient 3, whereas 7.0 / 2 uses floating-point arithmetic. Use small explicit values to test boundary behavior. Compare a value parameter, which receives its own copy, with a reference parameter, which can refer to the caller’s object. Trace separate statements and avoid inferring an output from expressions with unsequenced conflicting side effects. These examples introduce foundations; they do not claim to cover every C++ rule or the full target syllabus.
Traps that cost marks
Confusing assignment = with equality ==; integer division following the explicitly specified language’s rounding rule; assuming a loop runs one more or fewer time because of < versus <=; mutating a list while iterating over it; and thinking pass-by-value can swap caller variables in languages that copy primitives.