C-CAT C Programming Revision: Topics and Traps

revision Published 9 min read

C programming for C-CAT: what to revise

C is the base of Section B. Most questions are short code snippets, so the skill being tested is tracing code correctly, not remembering definitions. This guide lists the topics worth revising, the rules behind them and the traps that appear again and again.


Topic checklist

TopicWhat to be able to do
Data types and sizesState typical sizes, understand signed and unsigned, and implicit conversion
OperatorsApply precedence and associativity, and know that && and `
Control flowTrace nested loops, switch fall-through, break and continue
FunctionsPass by value, recursion tracing, function prototypes
ArraysIndex arithmetic, array-to-pointer decay, 2D arrays
PointersPointer arithmetic, pointer to pointer, pointer to array, function pointers
StringsNull terminator, strlen vs sizeof, common library functions
Storage classesauto, static, extern, register and their lifetime and scope
Structures and unionsMemory layout, padding, size of a union
Dynamic memorymalloc, calloc, realloc, free, leaks and dangling pointers
PreprocessorMacros with arguments, and why parentheses matter

Pointers and arrays

Pointers are the single biggest source of C questions. Keep these rules in mind:

  • Adding 1 to a pointer moves it by sizeof(type) bytes, not by 1 byte.
  • For an array a, the expression a decays to a pointer to its first element in most contexts, so a[i] is the same as *(a + i).
  • sizeof(a) on an array gives the total bytes, but once the array is passed to a function it becomes a pointer, so sizeof inside the function gives the pointer size.
  • *p++ increments the pointer after reading the value, because ++ binds before * in this expression, but the increment applies to p, not to the value.
  • A pointer to const data and a const pointer are different things: const int *p blocks changing *p, while int *const p blocks changing p.

Detailed notes: Pointers in C.


Operators, precedence and short-circuit

Many output questions are decided by one precedence rule.

  • Postfix ++ and -- bind tighter than unary * and &.
  • && has higher precedence than ||.
  • && and || stop evaluating as soon as the result is known, so a side effect on the right side may never run.
  • Integer division truncates: 5 / 2 is 2, and -5 / 2 is -2 in C99 and later.
  • Modifying the same variable twice between sequence points, such as i = i++ + ++i, is undefined behaviour. If a question asks for its output, the correct answer is usually “undefined” or “compiler dependent”.

Detailed notes: Operator precedence and Short-circuiting in C.


Storage classes

ClassScopeLifetimeDefault value
autoBlockUntil the block endsGarbage
static (local)BlockWhole program0
static (global)File onlyWhole program0
externGlobal across filesWhole program0
registerBlockUntil the block endsGarbage

A static local variable is initialised only once, so a function that increments it keeps the count between calls. This is a favourite output question.

Detailed notes: Storage classes in C.


Strings

  • A C string is a char array ending with '\0'. The array must have room for that extra byte.
  • strlen counts characters before '\0'. sizeof on an array counts every byte, including the terminator.
  • char s[] = "abc" creates a modifiable array. char *s = "abc" points to a string literal that must not be modified.
  • strcmp returns 0 when the strings are equal, not 1.

Detailed notes: Strings in C.


Structures, unions and memory

  • The size of a structure can be larger than the sum of its members because of padding added for alignment.
  • All members of a union share the same memory, so its size is the size of its largest member.
  • Every malloc needs a matching free. Using memory after free is a dangling pointer bug, and freeing twice is undefined behaviour.
  • calloc zero-initialises the memory, while malloc does not.

Detailed notes: Dynamic memory allocation.


A 7-day revision plan

  1. Day 1: data types, operators, precedence.
  2. Day 2: control flow and functions, with recursion tracing.
  3. Day 3: arrays and pointers.
  4. Day 4: strings and pointer arithmetic practice.
  5. Day 5: storage classes, structures and unions.
  6. Day 6: dynamic memory and the preprocessor.
  7. Day 7: mixed output-prediction questions under a timer.

Practise and revise further

For the full section list, see the C-CAT syllabus.


Key takeaways

  • Most C questions test code tracing, so practise by hand.
  • Master pointers and precedence first; they decide the most questions.
  • Know the static, extern and storage-class rules cold.
  • Watch for undefined behaviour in “tricky” expressions.

Frequently Asked Questions

1 How many C programming questions come in C-CAT Section B?

C-DAC does not publish a topic-wise split, so no exact number can be promised. C is consistently one of the most tested subjects in Section B, and the questions are mostly output prediction and concept checks.

2 Which C topics should I revise first?

Start with pointers and arrays, then operators and precedence, storage classes, strings, structures, and dynamic memory. These cover most of the questions that are asked repeatedly.

3 Are C-CAT C questions code-based?

Yes, a large share ask you to predict the output of a short snippet or find the error in it. Practise tracing code by hand instead of only reading theory.

4 How long does it take to revise C for C-CAT?

If you already know the basics, 5 to 7 focused days with daily output-prediction practice is usually enough for a full revision. Beginners need longer.

5 What is the most common mistake in C output questions?

Ignoring operator precedence, integer division and pointer arithmetic. Write the value of every variable after each line instead of guessing the result.