C Objective Interview Questions on Arrays

These C Objective Interview Questions on Arrays post providing basic, intermediate and Hard level examples in C Arrays. The Practice of these examples makes you good in C programming.


Passing array as an argument to a function means?

  1. Passing all the elements of array
  2. Passing only base address of array
  3. Passing the first element of array
  4. All of the above.

Answer :

Ans : 2, We can pass base address of array as a parameter to function

How can we increase the size of array dynamically?

  1. Not allowed
  2. Possible using calloc function
  3. Possible using realloc function
  4. Possible using malloc function.

Answer :

Ans : 3, calloc() function only allocates memory, we must use realloc() function to increase and decrease the size of array

Can a function return an array?

  1. Possible using pointers
  2. Not allowed in C program
  3. We can return only first element of array
  4. Can return element by element.

Answer :

Ans : 1, By returning base address using pointers

How can we find the size of the array?

  1. Size of array variable
  2. Size of sum of all array elements
  3. Neither a nor b
  4. We cannot find size of array

Answer :

Ans : 1, sizoeof(arr) where ‘arr’ is array variable

The elements in the array of this code, int array[5] = {5};

  1. 5, 5, 5, 5, 5
  2. 5, 0, 0, 0, 0
  3. 5, (garbage), (garbage), (garbage), (garbage)
  4. (garbage), (garbage), (garbage), (garbage), 5

Answer :

Ans : 2, If we initialize an array with one element, remaining gets initialized with 0 

Which of the following declaration is illegal?

  1. int a = 0, b = 1, c = 2;
    int array[3] = {a, b, c};
  2. int size = 3;
    int array[size];
  3. int size = 3;
    int array[size] = {1, 2, 3};
  4. All of the mentioned.

Answer :

Ans : 4, All are illegal declarations

What is “ptr” in the below declaration?
int *ptr [4]

  1. “ptr” is an array of 4 integers
  2. “ptr” is an array of integers
  3. “ptr” is a pointer to an array of 4 integers.
  4. None of the above.

Answer :

Ans : 3

Which of the following is the correct way to access the last element of the array arr, if arr is declared as int arr[3][3][4]?

  1. *(*((arr+2)+2)+4)
  2. *(*(*(arr+3)+3)+4)
  3. *(*(*(arr+2)+3)+4)
  4. *(*(*(arr+2)+2)+3)

Answer :

Ans : 4

What will be the size of the array if “arr” is a float array of 2 rows and 3 columns?

  1. 22
  2. 20
  3. 24
  4. 28

Answer :

Ans : 3, Total 6 elements and each element size is 4

C Objective Interview Questions On Arrays – Part3

Share this