Topics

Types, operators and expressions

Object sizes and limits under a stated GATE model, integer literal types, integer promotions and the usual arithmetic conversions, signed and unsigned pitfalls, the precedence and associativity ladder, division and remainder, bitwise operators and shifts, and preprocessor macro pitfalls with formatted I/O.

5 sheetsPCC-02PCC-03PCC-04

Control flow

if and else pairing, switch entry and fall-through, while, do-while and for loops, counting iterations, break, continue and goto, and loops that never end because of unsigned or floating counters.

1 sheetPCC-08

Functions, scope, lifetime and storage classes

Call by value and emulating call by reference with pointers, array parameters, argument evaluation order, parameter passing models in theory questions, block and file scope, storage duration, linkage and the auto, static, extern and register specifiers.

2 sheetsPCC-09PCC-10

Recursion

Base and recursive cases, stack frames, tracing prints placed before and after recursive calls, call trees, recursion depth, recurrences for the number of calls, memoisation, tail recursion and mutual recursion.

2 sheetsPCC-11PCC-12

Pointers and dynamic memory

Address and indirection operators, pointer arithmetic and comparisons, void pointers and null pointers, pointers to pointers, const placement, function pointers, reading declarations, malloc, calloc, realloc and free, leaks, double free, dangling and wild pointers, and linked structures.

3 sheetsPCC-13PCC-14PCC-18

Arrays and strings

Array to pointer decay and its exceptions, sizeof traps, array parameters, two-dimensional arrays with row-major address arithmetic, character arrays versus string literals, sizeof versus strlen and the common string library functions.

2 sheetsPCC-15PCC-16

Structures, unions, enums and typedef

Structure layout with implementation-defined padding, sizeof and offsetof, unions, enumerations, typedef, member access through pointers, structure copy and comparison, and bit fields.

1 sheetPCC-17

Defined, undefined, unspecified and implementation-defined behaviour

How to tell standard behaviour from implementation-defined, unspecified and undefined behaviour, sequencing and side effects, short-circuit evaluation, constraint violations that fail to compile, and how to answer GATE options when a program has no defined output.

2 sheetsPCC-06PCC-07

All Programming in C sheets

PCC-02Cheat sheet1 pageIn a paid pack

Types, Sizes, Limits and Literals

What the C standard fixes about object sizes and what it leaves to the implementation, the ILP32, LLP64 and LP64 data models, ranges of n-bit signed and unsigned integers, the type of an integer constant (decimal versus octal and hexadecimal, suffixes), character constants and escapes, octal traps, why there are no negative literals, sizeof as an unevaluated operator, and floating-point precision traps. Every value is compiled with gcc or computed by a script.

PCC-03Cheat sheet1 pageIn a paid pack

Integer Promotions and Arithmetic Conversions

The integer promotions, conversion rank, the usual arithmetic conversions applied per operator, signed and unsigned comparison pitfalls (-1 < 1u, sizeof and strlen differences), why -1L < 1u depends on the data model, integer division before floating conversion, truncation of floating values, and what happens when a value is converted to a narrower signed, unsigned or _Bool type.

PCC-04Cheat sheet1 pageIn a paid pack

Operators, Precedence and Associativity

The full C precedence and associativity ladder, integer division and remainder with negative operands, assignment and compound assignment values, the comma operator, the conditional operator and its result type, relational chains, logical results, maximal munch in tokens such as x+++y, and the lvalue rules that make some expressions fail to compile. All values are compiled with gcc.

PCC-05Cheat sheet1 pageIn a paid pack

Bitwise Operators, Shifts and Bit Tricks

The bitwise operators on promoted operands, masks to set, clear, toggle and test bit k, left and right shifts as multiplication and division for unsigned values, implementation-defined right shift of negative values, the shift cases that are undefined, the lowest-set-bit tricks with x & (x - 1) and x & -x, counting 1 bits, the XOR swap and its aliasing trap, and complementing small unsigned types.

PCC-19Cheat sheet1 pageIn a paid pack

Preprocessor, Macros and Formatted I/O

Macro expansion as token substitution before compilation, missing parentheses, arguments with side effects evaluated twice, multi-statement macros and do-while(0), stringising and token pasting, conditional compilation and include guards, typedef versus #define for pointer types, printf conversion specifiers, widths and precisions, printf's return value, scanf's return value and leftover input, and getchar with EOF.

PCC-08Cheat sheet1 pageIn a paid pack

Control Flow: Selection, Loops and Jumps

if and else pairing (dangling else), switch rules with fall-through and a default placed in the middle, while, do-while and for loops compared, formulas for counting loop iterations, break and continue (including continue inside a switch inside a loop), goto to leave nested loops, loops that never end because of an unsigned or floating counter, and the solved GATE CS 2025 Set 2 Q.33 subtraction loop.

PCC-09Cheat sheet1 pageIn a paid pack

Functions and Parameter Passing

Call by value as the only C mechanism, emulating call by reference with pointers, swap frames, changing the caller's pointer through a pointer to pointer, array and structure parameters, returning pointers to locals, prototypes and the removal of implicit declarations, unspecified argument evaluation order, the theory models (value, reference, value-result, name) with a computed example, and static versus dynamic scoping.

PCC-10Cheat sheet1 pageIn a paid pack

Scope, Lifetime, Linkage, Storage Classes

Scope (block, file, function prototype, and function scope for labels) and shadowing, storage duration (automatic, static, allocated), linkage (external, internal, none), the auto, static, extern and register specifiers in a lookup table with initial values, static locals initialised once, extern inside a block, declarations versus definitions and tentative definitions, compile errors from register and non-constant static initialisers, and a typical memory layout.

PCC-11Cheat sheet1 pageIn a paid pack

Recursion: Frames, Tracing and Output

Base case and recursive case, what a stack frame holds, a stack snapshot for a function that prints before and after its recursive call, a tracing routine based on the call tree, prints placed between two recursive calls (in-order), static counters shared by all frames and the unspecified order trap in return f(n - 1) + c, value-returning recursion (digit sum, digit reversal, fast power) and recursion that never reaches its base case.

PCC-12Cheat sheet1 pageIn a paid pack

Recursion: Calls, Depth and Recurrences

Separate recurrences for the value and for the number of calls, the call tree of naive Fibonacci with call and addition counts, two-call trees and Towers of Hanoi with closed forms, recursion depth versus total calls, the effect of memoisation on call counts, tail recursion and its loop form (C does not guarantee tail-call elimination), and mutual recursion with a prototype. Every count is compiled or computed by a script.

PCC-13Cheat sheet1 pageIn a paid pack

Pointers: Arithmetic, const and Levels

The address and indirection operators, declarators such as int *p, q, a memory snapshot of an array, a pointer and a pointer to pointer, pointer arithmetic scaled by the element size, pointer subtraction and comparison rules, one past the end, the *p++ family traced on an array, const placement with its compile errors, and null, wild and dangling pointers.

PCC-14Cheat sheet1 pageIn a paid pack

void *, Function Pointers, Declarations

Rules for void pointers (implicit conversion, no dereference, no arithmetic in ISO C), the null pointer constant, function pointers (declaration, assignment, two call forms, arrays of function pointers, callbacks and a qsort comparator), typedef for function pointer types, and the inside-out method for reading declarations such as int (*a)[10], int *f(int) and int (*(*f)(int))[3].

PCC-18Cheat sheet1 pageIn a paid pack

Dynamic Memory and Linked Structures

malloc, calloc, realloc and free with their return values, the safe realloc idiom, memory leaks, double free, use after free, dangling pointers from returning a local and wild pointers, which defects are undefined behaviour, self-referential structures, inserting at the head of a linked list with a diagram, unlinking a node in the right order, reversing a list, and freeing a whole list.

PCC-15Cheat sheet1 pageIn a paid pack

Arrays, Decay and Row-Major Addresses

Array to pointer decay and its three exceptions, the identities a[i] = *(a + i) = i[a], partial initialisation, a versus &a versus &a[0], sizeof of arrays and of array parameters, two-dimensional arrays as arrays of rows with types and strides, row-major and column-major address formulas with lower bounds and computed examples, passing a 2-D array to a function, and the solved GATE CS 2019 Q.24.

PCC-16Cheat sheet1 pageIn a paid pack

Strings and the String Library

Strings as null-terminated character arrays, string literals versus modifiable char arrays, a byte picture of three ways to hold the same text, sizeof versus strlen including embedded null bytes, strlen, strcpy, strcat, strcmp, strncpy, strchr and strstr with their traps, pointer offsets into a literal, a hand-written length and reverse, and the undefined cases: modifying a literal and reading an array with no terminator.

PCC-17Cheat sheet1 pageIn a paid pack

Structures, Unions, Enums and Padding

Structure layout under natural alignment with implementation-defined padding, a byte map of two member orders, sizeof and offsetof results, structures versus unions, member access with . and ->, structure assignment as a member-wise copy and why == does not compile, typedef of structures, enumeration constants, reading a union member other than the last one written, bit-fields that wrap, and the solved GATE CS 2018 Q.2.

PCC-06Cheat sheet1 pageIn a paid pack

Sequencing, Side Effects and Short-Circuit

Side effects and the C11 sequencing relations (sequenced before, unsequenced, indeterminately sequenced), the points where evaluation is ordered, a decision flow that classifies an expression as defined, unspecified or undefined, classic undefined expressions such as i = i++ and printf with i and i++, unspecified call order, short-circuit evaluation of && and || with skipped increments, the conditional and comma operators, and commas that are not operators.

PCC-07Cheat sheet1 pageIn a paid pack

Defined, Unspecified and Undefined Behaviour

The four behaviour categories of the C standard with definitions and catalogues of examples, constraint violations that the compiler must diagnose (and gcc rejects), compiler extensions, how to test for signed overflow before it happens, and a routine for answering GATE options when a program is undefined, unspecified or depends on the platform. Every compile error listed is checked by the build.

PCC-20Cheat sheet1 pageIn a paid pack

Programming in C Traps Sheet

Twenty-nine common wrong intuitions in C and recursion questions, each with the correct rule and a one-line reminder, grouped from types and conversions through operators, sequencing, control flow, functions, recursion, pointers, arrays, strings, structures, dynamic memory and macros, with links to the sheet that explains each rule.

PCC-21Cheat sheet1 pageIn a paid pack

Question Patterns and Solving Routines

Twenty recurring shapes of C and recursion questions (output prediction, static counters, recursion traces and call counts, pointer and array arithmetic, strings, structures, declarations, sequencing, conversions, loops, macros, dynamic memory and theory models), each with the recognition cue, the first step, the method and the check that changes the answer.

PCC-22Cheat sheet1 pageIn a paid pack

Master Last-Day Revision Sheet

A one-page summary of the pack: the GATE size model, the precedence ladder, conversion rules, the behaviour categories with the undefined cases to recognise, sequencing points, control-flow rules, storage classes, recursion counts, pointer and array strides, strings, structures, dynamic memory and macro rules.

Connected subjects

Digital LogicCompiler DesignData StructuresAlgorithms