C Fundamentals Formula Sheet for GATE CS: Rules, Traces and Revision Notes
Revise the C rules that most often change an answer. Use compact tables, worked traces, address formulas, memory notes, and a practical error checklist.
KnowledgeGate Team
Exam prep & CS education

C questions are rarely blocked by one theorem. Marks are lost by mixing up integer division, precedence, array decay, pointer arithmetic, storage duration, and undefined behaviour. Use this compact sheet and two worked traces for revision, not instead of learning C properly.
C fundamentals formula sheet: core terms and program structure
Term | Exact revision rule | When it matters |
|---|---|---|
Token | Smallest lexical unit | Syntax |
Keyword | Reserved language word | Naming |
Identifier | Entity name | Lookup |
Object | Typed storage region | Memory |
Type | Representation and permitted operations | Conversions |
Declaration | Introduces a name and type | Visibility |
Definition | Allocates an object or gives a function body | Linking |
Expression | Computes, designates, or has a side effect | Evaluation |
Statement | Action or control unit | Tracing |
Block | Braced declarations and statements | Local scope |
Scope | Where a name is visible | Lookup |
Lifetime | When an object exists | Access |
Linkage | Joins declarations of one entity | Multiple files |
int total = 0; declares and defines. In an external-definition pattern, extern int total; declares without itself allocating the object.
The path is source file -> preprocessing -> compilation -> assembly -> linking -> executable. Preprocessing handles directives, compilation analyses C, assembly makes object code, and linking combines it. Syntax or type errors are compile-time diagnostics, unresolved symbols are link-time errors, and run-time faults happen during execution.
The published C Programming Fundamentals: Worked Examples for GATE and C Programming by Yash Sir: Complete Guide with Worked Examples are broad teaching routes; this page is a compact cross-topic revision sheet built around formulas, traces, and memory rules.
For a topic-by-topic formula pass, see C Programming by Yash Sir Formula Sheet: Rules, Traces and Revision Notes; this page keeps the revision map cross-topic so one scan connects types, control flow, memory and functions.
C data types, conversions and arithmetic rules
Rule | Formula or result |
|---|---|
Unsigned |
|
Signed |
|
Character width |
|
Other basic-type widths | Implementation-dependent unless supplied |
Signed overflow | Undefined behaviour |
Unsigned arithmetic | Reduced modulo |
For N = 8, unsigned range is 0 to 2^8 - 1 = 255. Assuming two's complement, signed range is -2^7 = -128 to 2^7 - 1 = 127.
Integer arithmetic gives 17 / 5 = 3, 17 % 5 = 2, and 17 = (17 / 5) * 5 + 17 % 5 = 3 * 5 + 2. % accepts only integers. 7 / 2 = 3, but (double)7 / 2 = 3.5 because the cast occurs before division, not after the integer result.
For usual arithmetic conversions, identify operand types first. Use the question's widths and assumptions, not one machine's sizeof values.
C operators, short-circuiting and loop-count traces
The useful high-to-low precedence ladder is postfix; unary; multiplicative; additive; relational; equality; logical AND; logical OR; conditional; assignment. Precedence groups different levels. Associativity breaks same-level ties: most binary levels go left-to-right; unary, conditional, and assignment go right-to-left. Parenthesise intended grouping.
int x = 5, y = 2;
int a = x++ + y * 3;
int b = (x > 5) && (++y > 2);Point | Reason | State |
|---|---|---|
After |
|
|
After |
|
|
Now trace int sum = 0; for (int i = 1; i <= 16; i *= 2) sum += i;.
| 1 | 2 | 4 | 8 | 16 |
|---|---|---|---|---|---|
Successive | 1 | 3 | 7 | 15 | 31 |

The body runs five times, exiting at i = 32. Starting at 1 and doubling while i <= n gives floor(log2 n) + 1 executions for integer n >= 1, provided updates remain representable.
For outer i = 1..4 and inner j = 1..i, the count is 1 + 2 + 3 + 4 = 10; for limit n, it is n(n + 1) / 2.
C arrays, pointers and strings: the address formulas
For a valid index, a[i] == *(a + i), and pointer addition advances by the pointed-to type's size. Standard C defines pointer arithmetic only within the same array object or to the position one past its final element; that one-past pointer may be formed but must not be dereferenced. An array converts to its first-element pointer except under sizeof or unary &. A parameter int a[] becomes int *a. Therefore sizeof a / sizeof a[0] counts elements only for an actual array, not that parameter.
For zero-based row-major storage, address(A[i][j]) = B + ((i * C) + j) * w, where B is the base, C the column count, and w bytes per element. Given int A[3][4] = {{10,11,12,13},{20,21,22,23},{30,31,32,33}}, B = 1000, and w = 4:
address(A[2][3]) = 1000 + ((2 * 4) + 3) * 4 = 1000 + 11 * 4 = 1044.
The dedicated Arrays and Pointers in C Formula Sheet: Address Rules and Revision Notes owns the pointer-decay and address-trace drill; here the row-major identity is one bridge inside the full C revision set.
Also, A[2][3] = *(*(A + 2) + 3) = 33.
![Row-major 3 by 4 C array highlighting A[2][3] = 33 at address 1044 with the correct double-dereference formula.](https://cdn.knowledgegate.ai/blog-assets/blog_asset_1793316301467_72b4hz.jpg)
For char s[] = "GATE";, storage is 'G','A','T','E','\0'. There, sizeof s = 5 and strlen(s) = 4.
C functions, scope, storage duration and dynamic memory
C passes by value. With a = 3, b = 8, swap(a, b) changes copies. Passing swap(&a, &b) to int *p, int *q lets a temporary exchange the pointed-to values, giving a = 8, b = 3. A prototype describes the function type; a definition gives its body; parameters occur in declarations, arguments in calls.
Scope controls name visibility, storage duration controls object existence, and linkage connects declarations. An automatic local is recreated on entry. A local static int calls = 0; return ++calls; persists, returning 1, 2, 3 across three calls.
For n = 6, use int *p = malloc(n * sizeof *p);, check p != NULL, then run free(p); p = NULL;. calloc zeroes allocated bytes. Use a temporary for realloc so failure preserves the original. Continue with the C Language Course: Concepts, MCQs & Coding.
C traps that cost marks
Tempting expression | What goes wrong | Safe exam response |
|---|---|---|
| Unsequenced modification, undefined behaviour | Split the modifications |
| Valid indexes are | Check bounds |
Uninitialised automatic variable | Reading an indeterminate value | Initialise first |
Signed overflow | Undefined behaviour | Validate or use a suitable wider type |
Division by zero | Undefined behaviour | Guard the divisor |
Modify through | String literal is not modifiable | Use |
Never assign deterministic output to undefined behaviour. = may be mistaken for equality but assigns, so compare with ==. The tempting scanf("%d", x) incorrectly mirrors printf("%d", x): scanf needs an int *, so passing the value instead of its address can produce a diagnostic and an invalid write; use scanf("%d", &x). sizeof reports bytes, so element counting needs the actual-array formula. Do not assume that break exits every enclosing construct: in nested loops, it exits only the nearest loop or switch, so the outer loop continues. Use an outer-loop condition, a flag, or return when more than one nesting level must be left.
How GATE CS tests C fundamentals
Typical shapes cover converted expressions and side effects, loop counts, addresses, function-call state, scope, storage duration, null termination, and defined, undefined, unspecified, or implementation-dependent behaviour.
Run this 12-minute drill:
3 minutes: rewrite numeric and address formulas.
4 minutes: trace one expression and one loop in a state table.
3 minutes: solve one array or string question.
2 minutes: classify every doubtful result.
Key your error log to the violated rule. Use CS Fundamentals for Exams & Placements for adjacent notes and over 1,000 published C Programming questions for practice.
C fundamentals revision: the short version and next step
Identify types before values. Parenthesise grouping. Trace each statement. Use floor(log2 n) + 1 and n(n + 1) / 2 only for matching loops. Write the row-major formula first, separate arrays from pointers, and never invent undefined output.
The sheet works when you can derive an answer from a rule and trace, not merely recognise a formula.
Keep learning
Regular Language Properties: Formula Sheet and Revision Notes for GATE CS
Keep each regular-language rule beside its conditions. Revise identities, trace a product DFA and practise the quantifier order that makes a pumping-lemma proof work.
C Programming by Yash Sir Formula Sheet: Rules, Traces and Revision Notes
Revise C through compact rules, use cues and checked traces. The sheet covers expressions, loops, arrays, functions, storage and dynamic memory.
Grammar and CFG Formula Sheet: Rules, Worked Example and GATE Revision Notes
Revise CFGs in problem-solving order through precise rules, use cues, one consistent worked grammar, an LL(1) table, normal forms and a final audit routine.
Storage Classes, Structures and Enums in C: Formula Sheet with Worked Revision
Revise C declarations through three separate axes, then test them with a two-call trace, a byte-layout calculation and an enum sequence.





