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.

What are the different ways of initializing an array?

  1. int a[3] = {};
  2. int a[3] = {0};
  3. int a[3]={10};
  4. Only a and b
  5. All of the above

Answer :

Ans : 5

The elements in the array of the following code are 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 any array with one element, all the remaining elements initializes with 0

An array of similar data types which themselves are collection of dissimilar data type is

  1. Array of characters
  2. Array of integers
  3. Array of Structures
  4. All of the mentioned.

Answer :

Ans : 3

What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];)

  1. func(a);
  2. func(&a);
  3. func(*a);
  4. func(**a);

Answer :

Ans : 1, We just pass only base address of array but same type of array declaration is required in the called function to hold the address

What is the correct syntax for declaring three-dimensional int array?

  1. int *x[][];
  2. int **x[];
  3. int ***x;
  4. All the above.

Answer :

Ans : 4, All are allowed to declare three-dimensional array using pointers

Why array instead of a primitive variable?

  1. To structure and access the data effectively
  2. To store more than one element of different types
  3. To store more than one element of homogenous data
  4. Both a and b
  5. Both a and c.

Answer :

Ans : 5, We can store only homogeneous data elements but data processing become more effective

What array variable holds?

  1. Reference of memory block
  2. First element address of memory block
  3. First element in the memory block
  4. Both a and b
  5. Neither a nor b.

Answer :

Ans : 4, Both a and b are same

Can we access the element in the array which is out of bounds?

  1. No
  2. Compiler dependent
  3. yes
  4. Depends on the standard.

Answer :

Ans : 3, In C language it is allowed, but it results in garbage value

Can we initialize the array directly?

  1. Yes
  2. No
  3. Depends on compiler
  4. Depends on standard

Answer :

Ans : 1, By using assignment operator and {  }

C Objective Interview Questions On Arrays – Part2

Share this