Midterm Answer
Midterm Answer
A) The size of an array can be changed at B) Array elements are stored in contiguous
runtime. memory locations.
C) Array indexing starts from 1. D) Array can store different data types.
3. If an array int arr[5]; is partially initialized as int arr[5] = {10, 20};, what will be the value of
arr[3]?
A) 10 . B) 20 .
C) 0 . D) Garbage value.
A) stradd( ) . B) strcat( ) .
C) strtok( ) . D) strcpy( ) .
1
C) 4 . D) 0 .
9. A data structure that can store related information of different data types together is called
A) Array . B) String .
A) struct . B) structure .
C) union . D) enum .
A) . B) &
C) -> D) *
12. Which of the following is a correct way to define and initialize a structure in C?
struct Point {
int x;
int y;
};
A) struct Point p = {x: 10, y: 20}; B) struct Point p = {10, 20};
2
C) Point p = {10, 20}; D) Point p{10, 20};
C) To give a custom name to the structure D) To ensure the structure has public access.
for easier use.
15. What will happen if you try to access the next pointer of the last node in a singly linked list?
A) It will point to the first node in the list B) It will contain a garbage value
17. What happens when a node is inserted at the beginning of a singly linked list?
A) The new node becomes the last node in B) The new node becomes the first node, and
the list. its next pointer points to the previous first
node.
C) The new node points to the second node. D) The new node points to NULL.
3
18. What is the main advantage of using a linked list over an array?
A) Faster random access . B) Dynamic memory allocation .
19. In the case of a singly linked list, which pointer typically marks the end of the list?
A) The head pointer . B) The last pointer .
C) The next pointer of the last node, which D) The next pointer of the first node, which
points to NULL . points to NULL .
A) Memory for a linked list is allocated in B) Memory for each node is allocated
contiguous blocks. dynamically using malloc or calloc.
C) Memory for linked lists is allocated D) Memory is allocated only for the first
statically. node in the list.