Question 1
Which of the following data types will result in the largest memory allocation?
int
char
double
float
The IIT Madras BS Programming in C (Programming in C) End Term paper sat on 22 Dec 2024, in the September 2024 term, set QDB1: 25 questions for 100 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.
Which of the following data types will result in the largest memory allocation?
int
char
double
float
Correct answer
double
What is the primary difference between a function declaration and a function definition in C?
A function declaration specifies the name, return type, and parameters of a function, while a function definition provides the implementation of the function.
A function declaration provides the implementation of the function, while a function definition specifies only the function signature.
Both are the same, they can be used interchangeably.
Function declarations are only required for recursive functions.
Correct answer
A function declaration specifies the name, return type, and parameters of a function, while a function definition provides the implementation of the function.
Which of the following is not a valid memory segment in C?
Code segment
Heap segment
Register segment
Data segment
Correct answer
Register segment
6
7
8
9
Correct answer
6
a = 5, b = 3, c = 2
a = 1, b = 4, c = 3
a = 2, b = 2, c = 3
a = 3, b = 2, c = 4
Correct answer
a = 3, b = 2, c = 4
Counts the number of odd numbers from 1 to n.
Counts the number of even numbers from 1 to n.
The sum of odd numbers from 1 to n.
The sum of even numbers from 1 to n.
Correct answer
Counts the number of even numbers from 1 to n.
Correct answer
1
4
2
8
Correct answer
2
11
27
36
25
Correct answer
11
5
-5
15
Compilation error
Correct answer
-5
5
15
Compilation error
10
Correct answer
5
10
5
15
Compilation error
Correct answer
15
Correct answer
1
2
3
4
Correct answer
3
arr[0]: 42, arr[1]: 3.14
arr[0]: Undefined Behavior, arr[1]: 3.14
arr[0]: 42, arr[1]: Undefined Behavior
arr[0]: 42, arr[1]: 0.00
Correct answer
arr[0]: 42, arr[1]: 3.14
Correct answer
Which of the following best describes a macro in C?
A function stored in the stack memory.
A block of code replaced at runtime.
A block of code replaced during the preprocessing phase.
A predefined function in the C Standard Library.
Correct answer
A block of code replaced during the preprocessing phase.
Which of the following statements about conditional compilation is false?
Correct answer
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.
Which of the following statement(s) is/are true about arrays in C?
Arrays in C are zero-indexed.
The name of an array points to its first element in memory allocated for the array.
Arrays can hold elements of different data types.
Array elements are stored in contiguous memory locations.
Correct answers
Arrays in C are zero-indexed.
The name of an array points to its first element in memory allocated for the array.
Array elements are stored in contiguous memory locations.
Which of the following statement(s) is/are true about structures in C?
Structures can contain members of different data types.
The size of a structure is always the size of its largest member.
Structures can not be nested within other structures.
Members of a structure can be accessed using the dot operator.
Correct answers
Structures can contain members of different data types.
Members of a structure can be accessed using the dot operator.
Correct answer: 15
Correct answer: 9
Correct answer: 8
Correct answer: 11