PRACTICE • LEARN • GROW
Module 6: Arrays - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 6: Arrays - Final Quiz Progress
0 of 11 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What runtime bounds checking does standard C perform when accessing elements past the declared bounds of an array (e.g.
arr[10] on an array of size 5)?
A.
Throws an ArrayIndexOutOfBoundsException
B.
Automatically resizes the array
C.
None — C performs zero runtime bounds checks, leading to Undefined Behavior or Segmentation Faults
D.
Returns NULL
Explanation & Key
Correct Answer:
2
What is the output of the following program on a standard 64-bit architecture?
#include <stdio.h>
void inspect(int arr[10]) {
printf("%zu ", sizeof(arr));
}
int main() {
int arr[10];
printf("%zu ", sizeof(arr));
inspect(arr);
return 0;
}
A.
40 40
B.
40 8
C.
10 10
D.
8 8
Explanation & Key
Correct Answer:
3
What is the output of the following partial array initialization?
#include <stdio.h>
int main() {
int nums[5] = {7, 8};
for (int i = 0; i < 5; i++) {
printf("%d ", nums[i]);
}
return 0;
}
A.
7 8 Garbage Garbage Garbage
B.
7 8 0 0 0
C.
7 8 7 8 7
D.
Compile error
Explanation & Key
Correct Answer:
4
What is the output of the following unconventional array subscript expression?
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40};
printf("%d", 2[arr]);
return 0;
}
A.
Compile error
B.
30
C.
20
D.
Undefined behavior
Explanation & Key
Correct Answer:
5
Given
int matrix[4][5]; where each int occupies 4 bytes and base address &matrix[0][0] is 1000, what is the memory address of matrix[2][3] in row-major layout?
A.
1023
B.
1052
C.
1040
D.
1048
Explanation & Key
Correct Answer:
6
What is the output of the following pointer arithmetic on an array?
#include <stdio.h>
int main() {
int arr[] = {10, 20, 30, 40, 50};
int *p = &arr[3];
printf("%d", p[-2]);
return 0;
}
A.
20
B.
10
C.
30
D.
Undefined behavior
Explanation & Key
Correct Answer:
7
What is the output of this classic interview array mutation question?
#include <stdio.h>
int main() {
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d %d %d", i, j, m);
return 0;
}
A.
3 2 15
B.
2 1 15
C.
3 3 20
D.
2 2 15
Explanation & Key
Correct Answer:
8
What is the output of the following 2D array pointer dereferencing?
#include <stdio.h>
int main() {
int grid[2][3] = {{10, 20, 30}, {40, 50, 60}};
printf("%d %d", **grid, *(*(grid + 1) + 2));
return 0;
}
A.
10 60
B.
10 50
C.
20 60
D.
Compile error
Explanation & Key
Correct Answer:
9
Which of the following array declarations is ILLEGAL in C?
A.
int arr[5] = {0};
B.
int arr[] = {1, 2, 3};
C.
int arr[][3] = {{1, 2, 3}, {4, 5, 6}};
D.
int arr[][] = {{1, 2}, {3, 4}};
Explanation & Key
Correct Answer:
10
Why is row-major traversal
for(i) for(j) arr[i][j] significantly faster in performance than column-major traversal for(j) for(i) arr[i][j] on large matrices?
A.
Row indices consume less CPU registers
B.
Row-major traversal accesses contiguous adjacent memory words, maximizing CPU cache line hits and hardware prefetching
C.
The compiler cannot unroll column loops
D.
Column traversal requires 64-bit pointers
Explanation & Key
Correct Answer:
11
What is the output of the following array pointer comparison?
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
if (arr == &arr[0])
printf("Equal ");
if ((void*)arr == (void*)&arr)
printf("SameAddress");
return 0;
}
A.
Equal SameAddress
B.
Equal
C.
SameAddress
D.
Compile error
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong