In C, the trickiest short questions rarely come from one clean chapter. They hide in the miscellaneous bucket: storage classes, operator precedence, silent type conversions, macro expansion and bitwise tricks. Students often skip these rules, then lose easy marks in GATE and placement tests. The reliable method is to identify the governing rule first, then trace the expression, object lifetime or bit pattern line by line.
What miscellaneous C actually covers
Think of this topic as a concept map. Each branch tests a precise rule, so one overlooked detail can flip the output.
Sub-bucket | What decides the answer |
|---|---|
Storage classes | Scope, lifetime and linkage. |
Operators | Precedence and associativity. |
Type conversion | Promotions and sub-expression types. |
| Object or type size; its operand is normally not evaluated, except for variable-length arrays. |
Preprocessor macros | Token substitution without type checking. |
Bitwise operators | Per-bit combinations and shifts. |
| Constants, aliases and object access rules. |
Comma and ternary operators | Evaluation order and expression selection. |
Command-line arguments | The |
The full language map sits in C Programming by Yash Sir: Complete Guide with Worked Examples. Miscellaneous questions demand a narrower method: identify the controlling rule before tracing the code.
Storage classes: scope and lifetime decide the output
Storage class | Scope and lifetime | Linkage or purpose |
|---|---|---|
| Block scope, block lifetime | No linkage; default for locals. |
| Block scope, block lifetime | An optimisation hint only. |
| Block scope with program lifetime, or file scope | Retains a local value; can provide internal linkage at file scope. |
| Depends on the declaration | Usually declares an object or function defined elsewhere, without new storage. |
Consider a local static variable:
#include <stdio.h>
void tick(void) {
static int c = 0;
c++;
printf("%d ", c);
}
int main(void) {
tick();
tick();
tick();
}On call one, c changes from 0 to 1. The same object survives, so calls two and three change it to 2 and 3. The output is:
1 2 3Replace static int c = 0; with int c = 0;. A fresh automatic object starts at 0 on every call, so the output becomes 1 1 1.
Static changes lifetime, not the block scope of c. Static-storage and global objects default to zero. An uninitialised automatic object has an indeterminate value, often called garbage; reading it can produce undefined behaviour.

Operator precedence and associativity traps
Multiplication, division and remainder bind more tightly than addition and subtraction. These operators associate left to right within a level; assignment and unary operators associate right to left.
Work through this expression:
int result = 6 + 4 / 2 * 3 - 1;At the higher level, work left to right: 4 / 2 = 2, then 2 * 3 = 6. Now evaluate 6 + 6 - 1 left to right: 6 + 6 = 12, then 12 - 1 = 11. Therefore, result == 11.
Thus 10 - 4 - 3 means (10 - 4) - 3 = 6 - 3 = 3, not 10 - (4 - 3) = 9.
Do not invent an output for i++ + i++. The two modifications of i are unsequenced in C, so the expression has undefined behaviour. There is no correct printed number to guess.

Implicit type conversion and integer promotion
The assignment target does not decide the calculation. Determine each sub-expression's type first.
In float f = 5 / 2;, both operands are int, so integer division happens first. It truncates 5 / 2 to 2. That result is then converted to floating point, giving f == 2.0. In float f = 5.0 / 2;, one operand is floating point, so the division gives 2.5.
Now consider:
int a = -1;
unsigned int b = 1;
if (a > b)
printf("a is greater");
else
printf("b is greater");When int and unsigned int have the same rank, a converts to unsigned. With 32-bit unsigned int, -1 becomes 4294967295. Since 4294967295 > 1, the program prints a is greater.
The preprocessor: macros expand as text, not values
The preprocessor performs textual substitution. It does not call a typed function.
#define TWICE(x) x + x
int value = 5 * TWICE(1 + 2);The replacement is 5 * 1 + 2 + 1 + 2. Multiplication runs first, giving 5; the additions give 10. Therefore, value == 10, not 30.
Parenthesise both the parameter uses and the whole replacement:
#define TWICE(x) ((x) + (x))Now TWICE(1 + 2) becomes ((1 + 2) + (1 + 2)) = 6, so the outer multiplication gives 30. A macro can evaluate an argument more than once: TWICE(i++) substitutes i++ twice and creates undefined behaviour through unsequenced modifications. A function evaluates its argument once before the call.
Bitwise operators and the quick tricks they test
Let a = 5, which is 101 in binary, and b = 3, which is 011.
Expression | Binary result | Decimal result |
|---|---|---|
|
| 1 |
|
| 7 |
|
| 6 |
|
| 10 |
|
| 2 |
The complement ~a flips every bit in the full integer representation, so its decimal result depends on the width and representation.
The expression n & 1 is 1 for odd and 0 for even. For non-negative n, n << k multiplies by 2^k when representable, while n >> k divides by 2^k. Thus 5 << 1 = 10 and 5 >> 1 = 2.
Bitwise & and | differ from logical && and ||. Logical operators short-circuit; bitwise operators combine every bit and evaluate both operands.

How GATE and interviews test miscellaneous C
GATE commonly tests these patterns through short predict-the-output or find-the-bug programs in MCQ, MSQ or NAT form. The MCQ, MSQ or NAT? GATE Question Types explainer covers response formats and where negative marking applies. For any specific mark weight or rule, check the official information brochure published by the organising IIT, since recent GATE brochures specify those details.
Placement tests use the same style in programming MCQs. TCS NQT Exam Structure shows where technical preparation fits, while CS Fundamentals for Placements provides a structured route through the underlying subjects.
For every snippet, ask three questions in order:
What is the type of each sub-expression?
Which operator runs first, and what is its associativity?
Does each value persist, or is it recreated?
Use the same discipline for data-structure questions on BFS, DFS and connectivity.
The short version and your next step
staticchanges lifetime, not scope.Precedence groups operators; associativity resolves operators at the same level.
Integer arithmetic happens before a later float conversion, and a signed operand can convert to unsigned.
Macros substitute text, so parenthesise every parameter use and the full replacement.
Bitwise operators work bit by bit and are not logical operators.
Work these patterns on 20 to 30 solved snippets until every output is justified, not guessed. The C Programming Course is the end-to-end path for drilling the full language.




