What is the index of the first element in a C array?
A.
1
B.
-1
C.
0
D.
Depends on the compiler
Which of the following is the correct way to declare an integer array of size 10 in C?
A.
int arr;
B.
int arr(10);
C.
int arr[10];
D.
array int arr[10];
In the declaration int arr[5] = {1, 2};, what are the values of arr[2], arr[3], and arr[4]?
A.
Garbage values
B.
1, 2, 0
C.
0, 0, 0 (Partially initialized arrays set remaining elements to zero)
D.
Undefined
What is the size in bytes of int arr[20]; if an integer takes 4 bytes?
A.
20
B.
40
C.
80 (20 elements × 4 bytes each)
D.
100
What happens if you try to assign a value to an array element whose subscript exceeds its size (e.g., arr[10] for int arr[5])?
A.
A compile-time error occurs
B.
The program crashes immediately
C.
Undefined behavior
D.
The index wraps around to 0
Which of the following statements about arrays is false?
A.
Array elements are stored in contiguous memory locations.
B.
An array name holds the base address of the first element.
C.
Arrays can be resized at runtime in standard C
D.
An array can store elements of the same data type.
If an array is declared as int arr[10];, how many elements can it store?
A.
9
B.
10
C.
11
D.
Infinite
An array has 5 elements. What is the index of the last element?
A.
4
B.
5
C.
6
D.
7
What is the memory address of the first element of an array called?
A.
Foundation address
B.
Start address
C.
First address
D.
Base address
Which of the following is a valid way to initialize an array with all elements as zero?
A.
int arr[5] = {0};
B.
int arr[5] = {};
C.
int arr[] = {0, 0, 0, 0, 0};
D.
All of the above
What will be the output of the following code snippet?
int arr[5] = {5};
printf("%d, %d", arr[0], arr[1]);
A.
5, 5
B.
5, Garbage
C.
5, 0
D.
0, 0
Which of the following declarations is illegal in C?
A.
int size = 10; int arr[size];
B.
int arr[] = {1, 2, 3};
C.
int arr[5] = {1, 2, 3, 4, 5, 6};
D.
float prices[10];