Question 1
1 2 3
4 6 8
5 12 10
8 6 10

The IIT Madras BS Programming in C (Programming in C) End Term paper sat on 13 Apr 2025, in the January 2025 term, set 1: 20 questions for 43 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.
1 2 3
4 6 8
5 12 10
8 6 10
Correct answer
5 12 10
Which of the following is true about recursion?
Reduces the execution time significantly in comparison to using loops
Reduces the Memory requirement significantly in comparison to using loops
Reduces the Amount of lines of codes needed for performing tasks withrepeating sub-structure
All of these
Correct answer
Reduces the Amount of lines of codes needed for performing tasks withrepeating sub-structure
A 32-bit integer 0x12345678 is stored in memory starting at address 0x3000 on a little-endian system. Which of the following correctly represents the memory layout (address and stored values)?
0x3000: 120x3001: 34
0x3002: 56
0x3003: 78
0x3000: 780x3001: 56 0x3002: 34
0x3003: 12
0x3000: 560x3001: 78
0x3002: 12
0x3003: 34
0x3000: 120x3004: 34
0x3008: 56
0x300C: 78
Correct answer
0x3000: 780x3001: 56 0x3002: 34
0x3003: 12
Which of the following statements correctly declares a pointer variable ptr to hold the address of a character variable ch in C and assigns the address of ch to ptr?
char *ptr; ptr = &ch;
char *ptr; ptr = *ch;
char ptr; ptr = &ch;
char ptr; ptr = *ch;
Correct answer
char *ptr; ptr = &ch;
In C programming, which memory region is typically used for dynamic memory allocation?
Heap memory
Stack memory
Static memory
Code segment
Correct answer
Heap memory
What does the #define directive do in C preprocessor?
Declares a variable with the value to initialize it.
Defines textual symbols which are replaced by their values before compilation.
Defines a function which may have parameters
Includes a header file.
Correct answer
Defines textual symbols which are replaced by their values before compilation.
18
21
22
24
Correct answer
21
20 20
10 10
10 20
20 10
Correct answer
20 10
Hello
lo World
llo World
o World
Correct answer
lo World
[3,5,4,7,6,2]
[6,5,4,3,2,1]
[4,3,2,5,1,6]
[5,3,2,6,1,4]
Correct answer
[4,3,2,5,1,6]
19
45
26
20
Correct answer
19
{5, 5, 5, 5, 5}
{5, 0, 0, 0, 0}
{5, (garbage), (garbage), (garbage), (garbage)}
{(garbage), (garbage), (garbage), (garbage), 5}
Correct answer
{5, 0, 0, 0, 0}
Which of the following is not a valid storage class in C language?
extern
dynamic
register
auto
Correct answer
dynamic
Which of the following statements is/are true about the switch statement in C?
The break statement is compulsory to use with switch statement.
The default statement is compulsory to use with switch statement.
The default statement is optional with switch statement.
Multiple case labels can be used with switch statement.
Correct answers
The default statement is optional with switch statement.
Multiple case labels can be used with switch statement.
Which of the following statements about pointers is/are true?
A pointer can be incremented to point to the next memory location of its type.
A pointer variable cannot be reassigned after initialization.
Dereferencing a pointer gives the value stored at the memory address it holds.
Dereferencing a pointer gives the memory address it holds.
Correct answers
A pointer can be incremented to point to the next memory location of its type.
Dereferencing a pointer gives the value stored at the memory address it holds.
Correct answer: 5
Correct answer: 11
Correct answer: 5
Correct answer: 19
Correct answer: 32