Computer Fundamentals and Programming: Section C Essentials
Section C tests computer fundamentals and programming logic, with C as the reference language. Questions divide broadly into number systems and Boolean algebra, hardware, memory and operating-system basics, and C semantics: data types, operators, control flow, arrays, strings, functions, pointers, structures and recursion. A large share are "what is the output" items or statements about which construct is valid, so tracing code by hand is the core skill.
Fundamentals worth memorising
- Convert between bases by grouping bits: one hex digit covers 4 bits, one octal digit covers 3 bits.
- In C source, a literal beginning with 0 is octal, so 010 equals 8, and 0x10 equals 16.
- ASCII landmarks: 'A' = 65, 'a' = 97, '0' = 48; the difference between cases is 32.
- sizeof("abc") is 4 because the terminating '\0' is counted; strlen("abc") is 3.
- && and || short-circuit, so the right operand may never be evaluated.
- Arrays are zero-indexed, and an array name decays to a pointer to its first element when passed to a function.
Worked example
int n = 10, c = 0; while (n > 0) { n /= 2; c++; } printf("%d", c); Trace the loop: n becomes 10 → 5 → 2 → 1 → 0, with c incremented on each pass. Integer division truncates, so 5/2 is 2 and 1/2 is 0, which is what ends the loop. The output is 4. Writing 1/2 as 0.5 and assuming the loop continues is the classic error here.
Traps that cost marks
- Confusing = with ==, or placing a stray semicolon after for(...) or if(...).
- Post-increment: i++ supplies the old value to the surrounding expression, then increments.
- Accessing a[n] on an n-element array, which is out of bounds.
- Assuming an array passed to a function is copied; element changes persist in the caller.
- Recursion written without a base case that is actually reachable.