250+ TOP MCQs on Pointers Vs. Multi-dimensional Arrays and Answers

C programming questions on “Pointers Vs. Multi-dimensional Arrays”. One shall practice these questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C programming questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C programming questions on “Pointers Vs. Multi-dimensional Arrays” along with answers, explanations and/or solutions:

1. Which is true for a, if a is defined as “int a[10][20];”?
a) a is true two-dimensional array
b) 200 int-sized locations have been set aside
c) The conventional rectangular subscript calculation 20 * row + col is used to find the element a[row, col].
d) All of the mentioned
Answer: d
Clarification: None.

2. Which is true for b, if b is defined as “int *b[10];”?
a) The definition only allocates 10 pointers and does not initialize them
b) Initialization must be done explicitly
c) The definition only allocates 10 pointers and does not initialize them & Initialization must be done explicitly
d) Error
Answer: c
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         char a[10][5] = {"hi", "hello", "fellows"};
  5.         printf("%s", a[2]);
  6.     }

a) fellows
b) fellow
c) fello
d) fell
Answer: c
Clarification: Since every row in the array a[10][5] can contain only 5 characters, the a[2] element will hold “fello” i.e. 5 characters. There will not be any null character in a[2]. Since, the array is completely intialized, other rows (row a[3] will have only null characters. Hence, printf() using %s specifier will display fello only.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         char a[10][5] = {"hi", "hello", "fellows"};
  5.         printf("%pn", a);
  6.         printf("%p", a[0]);
  7.     }

a) same address is printed
b) different address is printed
c) hello
d) hi hello fello
Answer: a
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         char a[10][5] = {"hi", "hello", "fellows"};
  5.         printf("%d", sizeof(a[1]));
  6.     }

a) 2
b) 4
c) 5
d) 10
Answer: c
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         char a[1][5] = {"hello"};
  5.         printf("%s", a[0]);
  6.         return 0;
  7.     }

a) Compile time error
b) hello
c) Undefined behaviour
d) hellon
Answer: c
Clarification: None.

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

  1.     #include 
  2.     int main()
  3.     {
  4.         char *a[1] = {"hello"};
  5.         printf("%s", a[0]);
  6.         return 0;
  7.     }

a) Compile time error
b) hello
c) Undefined behaviour
d) hellon
Answer: b
Clarification: None.

8. Which of the following statements are true?

    P. Pointer to Array
    Q. Multi-dimensional array

a) P are static, Q are static
b) P are static, Q are dynamic
c) P are dynamic, Q are static
d) P are dynamic, Q are dynamic
Answer: c
Clarification: None.

  250+ TOP MCQs on Variable Length Argument and Answers

Leave a Comment

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

Scroll to Top