Q: 1 Which of the following correctly initializes an array in C?
int LA[5] = {1,2,3,4};
int LA[5] = (1,2,3,4,5);
int LA(5) = {1,2,3,4};
int LA(5) = (1,2,3,4,5);
[ Option A ]
In C, an array is initialized using square brackets [] to specify its size and curly braces {} to provide initial values. The statement int LA[5] = {1,2,3,4}; correctly follows this syntax. Even though the array size is 5 and only 4 values are provided, the remaining element is automatically initialized to 0.
Q: 2 To perform an operation on an array, the elements of the array need to be accessed. The process of accessing each element of an array is known as__________.
Merging
Traversing
Searching
Locating
[ Option B ]
The process of accessing each element of an array one by one in order to perform an operation such as printing, updating, or calculating is called Array Traversal.
Q: 3 What is the length of the array arr after this operation?
arr[]={1,2,3,4,5};
arr[1]=22;
arr[3]=44;
7
5
0
3
[ Option B ]
The array arr is initially defined as {1,2,3,4,5}, which contains 5 elements. The statements arr[1]=22; and arr[3]=44; only update the values at index 1 and index 3 of the existing array.
The array’s length remains unchanged by element assignments. It still contains 5 elements.
Q: 4 Which of the following is best describes an array?
A data structure that shows a hierarchical behavior.
Container of objects of similar types.
Container of objects of heterogeneous types.
All of the above.
[ Option B ]
An array is a data structure that stores a collection of elements of the same data type (homogeneous) in contiguous memory locations.
Q: 5 Which of the following correctly declares an array in C?
int suraku[20];
int suraku{20};
array suraku{20};
array suraku[20];
[ Option A ]
In C, an array is declared using the data type, array name, and size enclosed in square brackets [].
Syntax:
Data_Type Array_Name[Array_Size];
The statement int suraku[20]; follows the correct syntax for array declaration.
Q: 6 The name of 1-D array itself is a __________? Choose best answer.
Pointer to type of array
Pointer to integer
Constant pointer to integer
Constant pointer to type of array
[ Option D ]
The name of a 1-D array in C is a constant pointer to the type of array. This means it holds the address of the first element and cannot be changed to point to another location. For example, if you have int arr[6];, then arr is a constant pointer to int, always pointing to arr[0] and cannot be reassigned.
Q: 7 An __________ is a homogenous structure and starts with _________ index number.
Strings, One
Dictionary, Zero
Array, Zero
Array, One
[ Option C ]
An Array is a Homogeneous Data Structure, meaning it stores elements of the same data type. In most programming languages like C, C++, and Java, array indexing starts from 0.
Q: 8 How are elements of dynamic array stored in the memory?
Each element is stored at a random memory location.
Elements are dynamically linked to the next element in memory.
Elements are grouped and each group is stored at a random memory location.
Each element is stored in a contiguous memory location.
[ Option D ]
In a dynamic array, elements are stored next to each other (contiguous) in memory, just like a regular array (static array). The difference is that the size of a dynamic array is decided at runtime and memory is allocated dynamically in the heap section.
Q: 9 What are the disadvantages of static arrays?
Data structures like queue or stack cannot be implemented.
Index value of an array can be negative.
There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size.
Elements are sequentially accessed.
[ Option C ]
Static Arrays have a fixed size that must be defined at compile time. If fewer elements are stored than the allocated size, the unused locations remain empty, leading to wastage of memory space. This is the main disadvantage of static arrays.
Q: 10 What is a 2D Array?
An array that stores elements is a single row.
An array that stores elements is a single column.
An array that contains only integers.
An array of arrays.
[ Option D ]
A 2D array is an array of arrays, where each element of the main array is itself another array. It is commonly used to store data in the form of rows and columns, like a table or matrix.
Q: 11 The array name itself is a?
Pointer variable
Register variable
Ordinary variable
Powerful variable
[ Option A ]
In C, the array name itself behaves like a pointer constant. This means it holds the address of the first element of the array.
Q: 12 The name of 2-D array itself is a _________? Choose best answer.
Constant pointer to type of array
Constant pointer to 1-D array
Constant pointer to 1-D array of column size
Constant pointer to 1-D array of row size
[ Option C ]
In C, a two-dimensional array is essentially an array of one-dimensional arrays. Therefore, the name of a 2-D array represents the address of its first row, which itself is a 1-D array. Since the number of columns is fixed in memory layout, each row is treated as a 1-D array of fixed column size.
Q: 13 Which method is used to access elements in an array?
Sequential
Random
Alternative
Logarithmic
[ Option B ]
Arrays use the random-access method to access elements. This means any element of the array can be accessed directly using its index, without accessing previous elements. Due to this direct indexing and contiguous memory allocation, accessing arr[i] takes constant time (O(1)).
Q: 14 An array is finite collection of?
Heterogeneous
Homogeneous
Both (a) and (b)
Neither (a) nor (b)
[ Option B ]
An array is a data structure that stores a fixed number of elements of similar types. This means every value inside an array should be either all integers, all floats, all characters, etc. This property is called homogeneous because the elements are similar in type.
Q: 15 The memory address of the first element of an array is called.
Base Address
Floor Address
First Address
Foundation Address
[ Option A ]
The memory address of the first element of an array is known as the Base Address. All other elements of the array are accessed by adding an offset to this base address, based on the element size and index.
Q: 16 If an array has n elements, then what will be the index of the last element of the array?
0
n-1
n
n+1
[ Option B ]
In most programming languages like C C++, Java, arrays use Zero-Based Indexing. This means the index of the first element is 0. So, if an array has n elements, the indices will range from 0 to n−1.
Q: 17 If more than one subscript is used, an array is known as a__________.
One- dimensional array
Multi- dimensional array
Single dimensional array
Both (A) and (C)
[ Option B ]
If an array uses more than one subscript (index) to access its elements, it is called a Multi-Dimensional Array. Common examples include 2D arrays, which use two subscripts and are often used to represent tables or matrices.
Q: 18 Complete the following code to get sum of array elements:
#include<stdio.h>
int main()
{
int A[] = {1,2,3,4,5},i,sum = 0;
for(i=0;i<5;i++)
{
_____________;
}
printf(“%d”,sum);
return 0;
}
A[i]
sum = sum+i
sum +=A[i]
sum[i]
[ Option C ]
Q: 19 For a given array
int arr[]={1,7,3,7,5};
int p=arr[3]+arr[4];
What will be the value of p?
7
12
5
10
[ Option B ]
In C, array indexing starts from 0. For the array arr={1,7,3,7,5}, the elements are stored as:
The expression arr[3]+arr[4] therefore becomes 7+5, which evaluates to 12. Hence, the value of p is 12.
Q: 20 What is the output of the below code?
#include<stdio.h>
void main()
{
int arr[5]={11,22,33,44,55};
printf("%d", arr[5]);
}
55
Compile-Time Error
Run-Time Error
Garbage
[ Option D ]
In C, array indexing starts from 0. For the array int arr[5] = {11,22,33,44,55}; the valid indices are 0 to 4.
Here, arr[5] tries to access the 6th element, which is outside the bounds of the array. C does not perform bounds checking, so accessing arr[5] leads to undefined behavior. As a result, the program may print an unpredictable (garbage) value.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.