Array MCQ Quiz - Objective Question with Answer for Array - Download Free PDF

Last updated on May 30, 2025

Latest Array MCQ Objective Questions

Array Question 1:

How is a multi-dimensional array stored in the memory?

  1. Column-wise (Column-major order)
  2. Randomly
  3. Depends on the compiler
  4. Row-wise (Row-major order)

Answer (Detailed Solution Below)

Option 4 : Row-wise (Row-major order)

Array Question 1 Detailed Solution

Explanation:

A multi-dimensional array is a data structure that allows the storage of data in a grid or table-like format, making it possible to organize data in multiple dimensions (e.g., 2D, 3D). The most common form of multi-dimensional arrays are two-dimensional (2D) arrays, which can be visualized as a matrix with rows and columns.

Correct Option: Row-wise (Row-major order)

In most programming languages, multi-dimensional arrays are stored in memory in a row-major order. This means that the elements of the array are stored one row at a time. For example, consider a 2D array:

A[2][3] = {
    {1, 2, 3},
    {4, 5, 6}
};

In row-major order, this array would be stored in memory as follows:

1, 2, 3, 4, 5, 6

This storage format has significant implications for how we access and manipulate multi-dimensional arrays in memory. When accessing elements in a row-major order, the memory addresses of the elements are contiguous for a given row, which can lead to better cache performance and more efficient memory access patterns.

Array Question 2:

How do you declare a pointer to an integer?

  1. int *ptr;
  2. pointer int ptr;
  3. int ptr*;
  4. int ptr;

Answer (Detailed Solution Below)

Option 1 : int *ptr;

Array Question 2 Detailed Solution

Explanation:

Declaring a Pointer to an Integer

Correct Option: 1) int *ptr;

Definition: In the C programming language, a pointer is a variable that stores the memory address of another variable. When you declare a pointer to an integer, you are creating a variable that can hold the address of an integer variable.

Syntax: The correct syntax to declare a pointer to an integer is int *ptr;. This statement declares a variable ptr as a pointer to an integer type. The asterisk (*) indicates that the variable is a pointer, and the type int specifies that the pointer will point to an integer.

Here is a breakdown of the correct option:

  • int - This specifies the data type of the variable that the pointer will point to. In this case, it is an integer.
  • * - The asterisk indicates that the variable being declared is a pointer.
  • ptr - This is the name of the pointer variable.

Example: Below is a simple example demonstrating the declaration and usage of a pointer to an integer:

int main() {
    int number = 10; / Declare an integer variable
    int *ptr; / Declare a pointer to an integer

    ptr = &number; / Assign the address of the integer variable to the pointer

    printf("Value of number: %d\n", number); / Output the value of the integer variable
    printf("Address of number: %p\n", &number); / Output the address of the integer variable
    printf("Value stored in ptr: %p\n", ptr); / Output the address stored in the pointer
    printf("Value pointed to by ptr: %d\n", *ptr); / Output the value pointed to by the pointer

    return 0;
}

In this example, number is an integer variable, and ptr is a pointer to an integer. The address of number is assigned to ptr. The pointer ptr now holds the memory address of the integer variable number. The value pointed to by ptr can be accessed using the dereference operator (*).

Array Question 3:

Worst case scenario in case of linear search algorithm is __________. 

  1. Item is somewhere in the middle of the array
  2. Item is not in the array at all
  3. Item is the last element in the array 
  4. Item is the last element in the array or is not there at all

Answer (Detailed Solution Below)

Option 2 : Item is not in the array at all

Array Question 3 Detailed Solution

The correct answer is Item is not in the array at all.

key-point-image Key Points

  • In a linear search algorithm, the worst-case scenario occurs when the item being searched for is not present in the array at all.
  • This is because the algorithm will have to check each element of the array one by one until it reaches the end of the array, only to determine that the item is not there.
  • The time complexity for the worst-case scenario in linear search is O(n), where n is the number of elements in the array.
  • Other scenarios like the item being at the last position or somewhere in the middle will not be as time-consuming as the item being absent.

additional-information-image Additional Information

  • Linear search is a simple search algorithm that is easy to implement but not very efficient for large datasets.
  • It does not require the array to be sorted, which is an advantage over other more complex search algorithms.
  • In the average case, the time complexity of a linear search is O(n/2), but this simplifies to O(n) as constants are ignored in Big O notation.
  • Linear search can be used on both arrays and linked lists.

/ Example of a linear search algorithm in Python
def linear_search(arr, target):
    for i in range(len(arr)):
        if arr[i] == target:
            return i
    return -1

# Example usage:
arr = [4, 2, 7, 1, 9, 3]
target = 7
result = linear_search(arr, target)
if result != -1:
    print(f"Element found at index {result}")
else:
    print("Element not found in the array")

Array Question 4:

Which of the following is an advantage of using arrays? 

  1. Constant time insertion and deletion 
  2. Ability to store elements of different data types 
  3. Random access to elements using an index
  4. More than one of the above
  5. None of the above

Answer (Detailed Solution Below)

Option 3 : Random access to elements using an index

Array Question 4 Detailed Solution

Advantages of Using Arrays - khautorepair.com

The correct answer is Random access to elements using an index.

Key Points

  • Arrays allow random access to elements using an index, meaning you can directly access any element if you know its index.
  • This is highly efficient (constant time complexity O(1)) because it does not require traversing the entire structure to find an element.
  • Arrays provide a way to store multiple items of the same data type together, which helps in organizing data and improving performance.
  • They are useful in scenarios where the size of the data set is known beforehand and does not change frequently.

Additional Information

  • Arrays have a fixed size, which means once you define the size, it cannot be changed. This can be a limitation in some scenarios but ensures memory allocation is straightforward.
  • While arrays allow fast access to individual elements, they are not suited for operations that frequently add or remove elements, as these operations require shifting elements and can be time-consuming.
  • In many programming languages, arrays are zero-indexed, meaning the first element is accessed with index 0.
  • Arrays are a fundamental data structure and serve as the basis for more complex data structures like lists, stacks, queues, and matrices.

Array Question 5:

#include

int main()

{

int i = 5, j = 10, k = 15;

printf(\"%d \", sizeof(k /=i+j));

printf(\"%d\", k);

return 0;

}

Assume size of an integer as 4 bytes. What is the output of above program? 

  1. 2 1
  2. 4 1 
  3. 4 15
  4. More than one of the above
  5. None of the above

Answer (Detailed Solution Below)

Option 3 : 4 15

Array Question 5 Detailed Solution

The correct answer is 4 15.

Key Points

  • The expression sizeof(k /= i + j) is evaluated as sizeof(int) because k /= i + j is an integer expression.
  • In this case, sizeof(int) is 4 bytes.
  • However, the expression k /= i + j is also executed, which modifies the value of k.
  • Initially, i is 5, j is 10, and k is 15.
  • The expression k /= i + j translates to k = k / (i + j), which is k = 15 / (5 + 10), resulting in k = 1.
  • The final value of k is 1.

Additional Information

  • The sizeof operator returns the size of a type or expression in bytes.
  • In this example, sizeof is used to determine the size of an integer, which is 4 bytes.
  • The sizeof operator does not evaluate the expression but determines the type of the expression and returns the size of that type.

Top Array MCQ Objective Questions

Consider the following array declaration in ‘C’ language:

int array[] = {2, 3, 4, 5};

What will be the output of the following statement?

printf("%d", 2[array]);

  1. 4
  2. 3
  3. 2
  4. 5

Answer (Detailed Solution Below)

Option 1 : 4

Array Question 6 Detailed Solution

Download Solution PDF
Key Points

 An array is defined as the collection of similar types of data items stored at contiguous memory locations. Arrays are the derived data type in C programming language which can store the primitive type of data such as int, char, double, float, etc. C array is beneficial if you have to store similar elements.

int array[] = {2, 3, 4, 5}; This array storage be like, 

F2 Harshita Madhuri 12.02.2022 D2

The above array at index I can be accessed by, a[i], i[a], *(a+i) or *(i+a) all the above representations all are equal and gives the i th index value.

printf(%d', 2[array]); So, it gives the 2nd  index value. i.e 4.

Hence the correct answer is 4.

Additional InformationProgram: 

#include
int main()
{
    int arr[] = { 2, 3, 4, 5 };
    printf("%d ",arr[2]);
    printf("%d ",2[arr]);
    printf("%d ",*(2+arr));
    printf("%d ",*(arr+2));
    return 0;
}

Output: 4 4 4 4

So above given 2nd index value is 4 for all above print statements.

The declaration int arr [2][5]; will allocate ______ bytes.

  1. 20
  2. 10
  3. 40
  4. 2

Answer (Detailed Solution Below)

Option 3 : 40

Array Question 7 Detailed Solution

Download Solution PDF

The correct answer is 40

Key Points

In int arr[2][5] creates a 2D array, with two 2 and 5 columns.  

A typical integer data type variable requires 4 bytes of space. 

Here we are creating 2 rows and 5 columns. So, the total number of variables that can be stored is  2 x 5 = 10 variables. 

So, one integer type variable takes 4 bytes space, 10 such variables will take a space of 

Thus, the answer is 4 x 10 = 40 bytes.

Mistake PointsNote: In some old systems, int used to be 2 bytes for each variable. In that case, the answer would become 20 bytes. However, modern standards are that of 4 bytes for int data type

If integer requires two bytes space, then what will be the size of the following 'C’ array?

int array[3][4]=(0);

  1. 24 bytes
  2. 12 bytes
  3. 7 bytes
  4. 14 bytes

Answer (Detailed Solution Below)

Option 1 : 24 bytes

Array Question 8 Detailed Solution

Download Solution PDF
Key Points

 An array is defined as the collection of similar types of data items stored at contiguous memory locations. 

int array[3][4] = (0);

Here Array is an integer array. which is in a two-dimensional array of 3 rows and 4 columns. So each row has 4 elements and there are three rows.

Hence total number of elements = 3 x 4 =12

Each element of size = 2 bytes.

So size of array is = 12 x 2 bytes =24 bytes.

Hence the correct answer is 24 bytes.

Find the number of elements in the following array.

char si [] = "India is great";

  1. 3
  2. 5
  3. 15
  4. 12

Answer (Detailed Solution Below)

Option 3 : 15

Array Question 9 Detailed Solution

Download Solution PDF

The correct answer is option 3.

Concept:

Array:

An array is a collection of data elements that are similar in nature and are stored in adjacent memory locations. It is the most basic data structure because each data element can be accessed directly using only its index number. When we store strings in an array, they are stored as a single character in a single index of the array.

The string is a collection of characters that are treated as a single data item and is terminated by the null character '\0'.

Explanation:

char si [] = "India is great";

The above declaration is a dynamic allocation of array name si of character datatype.

F1 Shraddha Harshita 25.02.2022 D2

Hence the correct answer is 15.

Which of the following expression will delete the entire array pointed to by q?

  1. delete all q; 
  2. delete array q;
  3. delete * q;
  4. delete[ ] q;

Answer (Detailed Solution Below)

Option 4 : delete[ ] q;

Array Question 10 Detailed Solution

Download Solution PDF

The correct answer is delete[ ] q;

Key Points

This expression informs the compiler to not just delete the memory pointed to by 'q' but to also properly destruct every object in the array. Thus, it's optimal for freeing up memory allocated for arrays in dynamic memory.

EXPLANATION:

In C++, when you allocate an array dynamically, you use the new[] operator. This allocates a block of memory sufficient to hold the array, and returns a pointer to the first element. Here's an example:

  • int* arr = new int[10];  / Allocates memory for an array of 10 integers.

When you're done with this dynamically allocated memory, it's important to free it up to prevent memory leaks in your program. You do this by using the delete[] operator, which you apply to the pointer:

  • delete[] arr;  / Frees the memory for the array of 10 integers.

 

Consider the following ANSI C program.

#include

int main()

{

   int arr[4][5];

   int i, j;

  for(i =0; i<4; i++)

  {

    for (j =0; j<5; j++)

    {

       arr [i][j] = 10 * i + j;

    }

  }

     print("%d", *(arr[1] + 9));

     return 0;

}

What is the output of the above program?

  1. 14
  2. 20
  3. 30
  4. 24

Answer (Detailed Solution Below)

Option 4 : 24

Array Question 11 Detailed Solution

Download Solution PDF

code:

#include

int main(){

int arr[4][5];

int i, j;

for(i =0; i<4; i++){

for (j =0; j<5; j++){

arr [i][j] = 10 +i + j;

}

}

print("%d", *(arr[1] + 9));

return 0;

}

Key Points

  1. C doesn't check array boundaries. A segmentation fault will only occur if you try to dereference a pointer to memory that your program doesn't have permission to access. Simply going past the end of an array is unlikely to cause that behavior. Undefined behavior is just that - undefined. It may appear to work just fine, but you shouldn't be relying on its safety.
  2. Your program causes undefined behavior by accessing memory past the end of the array. In this case, it looks like one of your str[i] = c writes overwrite the value in i.

Explanation:

*(arr[1] + 9) can be written as arr[1][9].

as C doesn't follow bound check and follow the row major ordering

arr[1][5] = arr[2][0]  / arr[1][4] will be first row of array and then arr[2][0] will be second row of array 

arr[1][6] = arr[2][1]

arr[1][7] = arr[2][2]

arr[1][8] = arr[2][3]

arr[1][9] = arr[2][4]

arr[2][4] = 10*i + j = 10*2+4 = 24

Option 4 is the answer.

Consider the following declaration of an array in ‘C’ language:

int A[6] = {1, 2, 3, 5};

Which of the following statements is true?

  1. Both A[2] and 2[A] represent the value 2.
  2. Both A[2] and 2[A] represent the value 3
  3. A[2] is the correct way to access an element of A, but 2[A] will give an error
  4. The last two elements of the array A are 3 and 5

Answer (Detailed Solution Below)

Option 2 : Both A[2] and 2[A] represent the value 3

Array Question 12 Detailed Solution

Download Solution PDF

Concept:

An array is a data structure that contains a group of elements. These elements are all of the same data type, such as an integer.

To access element from an array subscript(index) and array name is required

Explanation:

Array name: A

index

0

1

2

3

element

1

2

3

5

To access 3rd element in an array A[2] or 2[A] is used.  Therefore Both A[2] and 2[A] represent the value 3

Important point:

A[0] represent the value 1st element

Consider the following C program segment.

#include

int main()
{
    char s1[7] = "1234";
    char *p;

    p = s1 + 2;
    *p = '0';

    printf("%s", s1);

    return 0;
}

What will be printed by the program?

  1. 12
  2. 120400
  3. 1204
  4. 1034

Answer (Detailed Solution Below)

Option 3 : 1204

Array Question 13 Detailed Solution

Download Solution PDF

F1 R.S Shraddha 17.01.2020 D2

Where \0 is a null character 

After *p = '0';   \\s1[2] = '0'

100  101 102 103  104

1

2

0

4

\0

printf(“%s”, s1) will print all starting from address location 100 until the null character.

Output: 1204 

Which of the following initialization statement store six integer values in array?

  1. int array; 
  2. int array[5]; 
  3. int array(6);
  4. int array[6];

Answer (Detailed Solution Below)

Option 4 : int array[6];

Array Question 14 Detailed Solution

Download Solution PDF

The correct answer is int array[6];

Key Points

  • In C, C++, and similar languages, arrays start at index 0. So, int array[6]; would give you an array with six elements, indexed from 0 to 5.
  • array[6]

      qImage6571d1f623521d106a100d52

  • The other statements either provide an incorrect syntax for array initialization or denote an array of a different size.
  • int numbers[6];  / Declares an array named numbers to store 6 integers

    numbers[0] = 10;
    numbers[1] = 20;
    numbers[2] = 30;
    numbers[3] = 40;
    numbers[4] = 50;
    numbers[5] = 60;

    / Accessing elements:
    int firstElement = numbers[0];  / firstElement will be 10

Additional Information

  • Arrays: In an array, data is stored in a contiguous block of memory. Each element in the array can be accessed directly using its index.

The correct syntax for initialization of a one-dimensional array is _________.

  1. ​num[4] = {1,2,3,4};
  2. num[4] = 0
  3. num[4] = {1 2 3 4};
  4. num[4] = {1;2;3;4};

Answer (Detailed Solution Below)

Option 1 : ​num[4] = {1,2,3,4};

Array Question 15 Detailed Solution

Download Solution PDF

The correct answer is: ​num[4] = {1,2,3,4};

Concept:

The array is a data structure used to store elements in linear order. 

The array is declared to store elements of a particular data type.

Explanation:

  • In the following declaration, the array name is num.
  • The size of the array is four.
  • The array is initialized with four elements 1,2,3,4.

Key Points

  • The array needs to be of a particular data type.
  • The elements that need to be stored in the array must be present in curly braces {}. Each element in curly braces must be separated with a comma.
  • The array declaration statement must be enclosed with a semicolon.

Additional Information

  • The two-dimensional array can be declared as num[][].
  • The number of square brackets [] shows the dimensions of the array.
  • The array cannot be initialized directly with an integer or any other values. The num[4] = 0 is invalid initialization of the array, as the elements 0 that need to be stored in an array must be present in curly braces.
  • The num[4] = {1 2 3 4}; is an invalid declaration as the elements that need to be stored in an array are not separated by commas, but only a space is used.
  • The num[4] = {1;2;3;4}; is also invalid as the semicolon is used to separate elements of an array instead of commas.
Get Free Access Now
Hot Links: teen patti 500 bonus teen patti star login all teen patti teen patti earning app teen patti master gold download