Indian Institute of Technology Madras
BS Degree Programme · Examination & Study Paper
Programming in C
Most repeated questions
Examination Instructions & Guidelines
- Solve on notebook/paper first before checking solutions.
- MCQ: Exactly 1 option is correct. Negative marking applies.
- MSQ: One or more options correct. Select all to score.
- NAT: Numerical response. No negative marking.
- Scientific calculator allowed for all calculations.
- Official answer key is sealed at the end of this sheet.
Type 1 · asked 3 times · Conditions & loops
Trace a loop that uses continue and break
- Q1NAT5 Marks·Write the numberEnd Term · 31 Aug 2025 (AN)Key ↓
Consider the following C code:
What will be the output of the given program?Your answer: - Q2MCQ4 Marks·Choose one optionQuiz 1 · 26 Oct 2025 (AN)Key ↓

- A0 1 2 5 6
- B0 1 5 6
- C1 2 3 6
- D1 2 3 5 6
- Q3NAT4 Marks·Write the numberQuiz 1 · 26 Oct 2025 (AN)Key ↓
Your answer:
Type 2 · asked 2 times · Operators & expressions
How && and || short-circuit evaluation works
- Q4MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓

- A

- B

- C

- D

- A
- Q5MSQ2 Marks·Choose all correct optionsQuiz 1 · 26 Oct 2025 (AN)Key ↓
Which statement is true about short-circuit evaluation in C?
- AIn expr1 && expr2, if expr1 is false, expr2 is not evaluated.
- BIn expr1 || expr2, if expr1 is true, expr2 is not evaluated.
- CIn expr1 && expr2, if expr1 is true, expr2 is not evaluated.
- DIn expr1 || expr2, if expr1 is false, expr2 is not evaluated.
Type 3 · asked 2 times · Computer basics & number systems
Store a hex value in memory on a big/little-endian system
Type 4 · asked 2 times · Operators & expressions
Evaluate bitwise AND / OR of two small integers
Type 5 · asked 2 times · Operators & expressions
Pre-increment vs post-increment behaviour
- Q10MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓

- APre-increment changes the value after the expression is evaluated, while post- increment changes it before the expression is evaluated.
- BPre-increment changes the value before the expression is evaluated, while post-increment changes it after the expression is evaluated.
- CPre-increment is used with integers, while post-increment is used with floating-point numbers.
- DPre- and Post-increment are identical in operation. They are two ways of writing the same statement.
- Q11MCQ3 Marks·Choose one optionQuiz 1 · 26 Oct 2025 (AN)Key ↓

- Aa = 13, b = -4, c = 12
- Ba = 12, b = -3, c = 11
- Ca = 14, b = -5, c = 13
- Da = 11, b = -2, c = 10
Type 6 · asked 2 times · Conditions & loops
Trace a nested loop that checks (i + j) % 2 == 0
Type 7 · asked 2 times · Functions & recursion
What happens to the call stack in recursion
- Q14MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓
What is a potential risk of a recursive function that is not properly terminated with a base case?
- AIt will cause a compile-time error.
- BIt will always return an incorrect value.
- CIt can lead to a stack overflow, as the function calls consume all available stack memory.
- DThe program will terminate gracefully with a success message.
- Q15MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓
When a recursive function is called, how does the call stack (or program stack) manage the function calls?
- AEach new recursive call overwrites the previous function call on the stack.
- BEach new recursive call adds a new stack frame to the top of the stack for its local variables and parameters.
- CThe call stack is not used for recursive functions; a separate data structure is used.
- DThe recursive calls are stored in a queue, waiting to be processed in order.
Type 8 · asked 2 times · Functions & recursion
Pass-by-value vs pass-by-reference (pointers) to modify arguments
- Q16MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓
What is the fundamental conceptual difference between "pass-by-value" and "pass-by-reference" for function parameters in C?
- APass-by-value is used for primitive types, while pass-by-reference is used for composite types.
- BIn pass-by-value, a function works with a copy of the argument, whereas in pass-by-reference, it works with the original variable via its memory address.
- CPass-by-value allows a function to modify the original variable, while pass-by- reference protects the original variable from modification.
- DThe choice between pass-by-value and pass-by-reference is made automatically by the compiler based on the variable's type.
- Q17MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓

- A

- B

- C

- D

- A
Type 9 · asked 2 times · Functions & recursion
Trace a recursive function using n % k and n / k
Type 10 · asked 2 times · Pointers & dynamic memory
Use & and * to reach a variable through a pointer
Type 11 · asked 2 times · Pointers & dynamic memory
Change a variable through a pointer or double pointer
Type 12 · asked 2 times · Pointers & dynamic memory
Dereference a pointer after pointer arithmetic on an array
Type 13 · asked 2 times · Pointers & dynamic memory
Trace a malloc'd array filled by a recurrence
Type 14 · asked 2 times · Pointers & dynamic memory
Which memory region (stack/heap) stores what
- Q28MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓
In C programming, which memory region is typically used for dynamic memory allocation?
- AHeap memory
- BStack memory
- CStatic memory
- DCode segment
- Q29MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓
In C programming, which memory region is primarily used for storing local variables of functions and function call information?
- AHeap memory
- BStack memory
- CStatic memory
- DCode segment
Type 15 · asked 2 times · Arrays & strings
What an array holds after partial initialisation
Type 16 · asked 2 times · Arrays & strings
Sum elements of a 2D array by index
Type 17 · asked 2 times · Structs, unions & enums
Size and meaning of a union
- Q34MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓

- A

- B

- C

- D

- A
- Q35MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓
A special data type is declared where multiple members share the same memory location. The size of an instance of this type is equal to the size of its largest member. What kind of data type is this?
- A

- B

- C

- D

- A
Type 18 · asked 2 times · Structs, unions & enums
Access a struct member with . or ->
Type 19 · asked 2 times · Structs, unions & enums
Find integer values of enum constants
Type 20 · asked 2 times · File I/O & the preprocessor
What fopen does in a given mode (r / w)
- Q40MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓

- A

- B

- C

- D

- A
- Q41MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓

- A"New Content" is appended to the end, resulting in "Hello WorldNew Content".
- BThe file is cleared, and only "New Content" is written.
- CThe code will fail to open the file because it already exists.
- D"New Content" is inserted at the beginning, pushing "Hello World" to the end.
Type 21 · asked 2 times · File I/O & the preprocessor
Compare two file I/O functions (fprintf/fputs, fscanf/fgets)
Type 22 · asked 2 times · File I/O & the preprocessor
When and how the preprocessor replaces macros
- Q44MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (AN)Key ↓
When a macro is used in a C program, at what stage is its definition replaced into the code?
- A

- B

- C

- D

- A
- Q45MCQ4 Marks·Choose one optionEnd Term · 31 Aug 2025 (FN)Key ↓
What is the primary purpose of the C preprocessor?
- ATo execute the program's logic before the main function.
- BTo convert the source code into machine language.
- CTo process directives and modify the source code before compilation.
- DTo manage dynamic memory allocation during runtime.
Type 23 · asked 2 times · File I/O & the preprocessor
Expand a macro without parentheses and find the result
Official KeyMaster Answer Key & Explanations
Official answer keys from IIT Madras BS past papers. Click any question to review.
Reveal KeyCollapse Key
Master Answer Key & Explanations
Official answer keys from IIT Madras BS past papers. Click any question to review.





What is the output of the program?
















What will be the output of the given C program?