Tags: #◇Computer Science #◇CCPROG1 #◇C Programming #◇Reviewer #◇Finals
CCPROG1 Comprehensive Finals Reviewer
◇Overview
This reviewer consolidates the fundamental programming curriculum in C from CCPROG1: Logic Formulation and Introductory Programming. It spans the complete software development lifecycle, algorithmic logic formulation, flowcharts, variable typing, operators and expressions, modular decomposition with functions, control structures (selection and iteration), testing/debugging methodologies, and coding standards.
◇1. Core Syntax & Data Representation Matrix
| Concept | Specifier / Syntax | Size (x86-64) | Range / Behavior |
|---|---|---|---|
char | %c | 1 byte | to (ASCII code) |
int | %d or %i | 4 bytes | to (approx ) |
float | %f | 4 bytes | 6-7 decimal digits precision |
double | %lf | 8 bytes | 15-17 decimal digits precision |
Division / | int / int vs float / int | N/A | Integer division truncates towards zero (). Float division yields . |
Modulo % | a % b | N/A | Remainder of integer division; operands must be integral. |
Operator Precedence Hierarchy (Highest to Lowest)
- Parentheses:
() - Postfix / Unary:
++,--,+,-,! - Multiplicative:
*,/,% - Additive:
+,- - Relational:
<,<=,>,>= - Equality:
==,!= - Logical AND:
&&(Short-circuiting: evaluates right only if left is true) - Logical OR:
||(Short-circuiting: evaluates right only if left is false) - Assignment:
=,+=,-=, etc.
◇2. Modular Decomposition & Functions
In C, functions enforce encapsulation and procedural abstraction.
- Pass-by-Value: C passes all primitive parameters by value. A local copy is allocated on the activation frame (call stack). Modifications to the formal parameter inside the callee do not affect the caller's actual arguments.
- Scope & Storage Duration:
- Block scope: Visible only within enclosing
{}. - Function prototype: Declares return type and signature before
main()so the compiler can perform type checking.
- Block scope: Visible only within enclosing
◇3. Control Flow Architecture
Selection Structures
if ... else if ... else: Evaluates sequential boolean conditions.switch(expr): Evaluates integral expressions against constant labels. Requires explicitbreak;to prevent fallthrough.
Iterative Structures
while(condition): Pre-test loop. Executes 0 or more times.for(init; condition; update): Deterministic count-controlled loop.do ... while(condition);: Post-test loop. Guarantees execution at least once.
◇4. High-Yield Exam Checklist
- Does integer division discard decimal portions? ().
- Does
scanf("%d", &val)require an address-of operator&? - Did you avoid placing a semicolon after
if(...)orwhile(...)loops? - Are loop boundary conditions checked for off-by-one errors ( vs )?
- Are all accumulator variables (
sum,count) initialized to zero before loops? - Does
switchuse integral types (int,char) and includedefault:?
◇References & Navigation
ACTIVE RECALL VERIFICATION
Select an answer to verify conceptual comprehension and reveal the technical rationale.
What is the output of printf("%d", 14 / 4 * 4 + 14 % 4); in C?
Given int x = 5, y = 10;, what is the value of x after if (x > 3 || ++y < 12) executes?
What happens if a non-void function in C finishes execution without an explicit return statement?
Which loop structure is guaranteed to execute its loop body at least once?
In C, what is the effect of writing while (x = 0) instead of while (x == 0)?