250+ TOP MCQs on Pointers and Arrays and Answers

’s MCQs on C helps anyone preparing for placement in HP and other companies. Anyone looking for HP placement papers should practice these questions continuously for 2-3 months, thereby ensuring a top position in placements.

Here is a listing of online C quiz on “Pointers and Arrays” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[4] = {1, 2, 3, 4};
  5.         printf("%dn", *ary);
  6.     }

a) 1
b) Compile time error
c) Some garbage value
d) Undefined variable
Answer: a
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         const int ary[4] = {1, 2, 3, 4};
  5.         int *p;
  6.         p = ary + 3;
  7.         *p = 5;
  8.         printf("%dn", ary[3]);
  9.     }

a) 4
b) 5
c) Compile time error
d) 3
Answer: b
Clarification: None.

3. What are the different ways to initialize an array with all elements as zero?
a) int array[5] = {};
b) int array[5] = {0};
c)

   int a = 0,  b = 0,  c = 0;
   int array[5] = {a, b, c};

d) All of the mentioned
Answer: d
Clarification: None.

4. What are the elements present in the array of the following C code?

a) 5, 5, 5, 5, 5
b) 5, 0, 0, 0, 0
c) 5, (garbage), (garbage), (garbage), (garbage)
d) (garbage), (garbage), (garbage), (garbage), 5
Answer: b
Clarification: None.

5. Which of the following declaration is illegal?
a)

   int a = 0, b = 1, c = 2;
   int array[3] = {a, b, c};

b)

   int size = 3;
   int array[size];

c)

   int size = 3;
   int array[size] = {1, 2, 3};

d) All of the mentioned
Answer: c
Clarification: None.

6. An array of similar data types which themselves are a collection of dissimilar data type are ___________
a) Linked Lists
b) Trees
c) Array of Structure
d) All of the mentioned
Answer: c
Clarification: None.

7. Comment on an array of the void data type.
a) It can store any data-type
b) It only stores element of similar data type to first element
c) It acquires the data type with the highest precision in it
d) You cannot have an array of void data type
Answer: d
Clarification: None.

8. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int ary[4] = {1, 2, 3, 4};
  5.         int p[4];
  6.         p = ary;
  7.         printf("%dn", p[1]);
  8.     }

a) 1
b) Compile time error
c) Undefined behaviour
d) 2
Answer: b
Clarification: None.

  250+ TOP MCQs on Line Input & Output and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top