Open In App

C | Misc | Question 6

Like Article
Like
Save Article
Save
Share
Report issue
Report

Assume the following C variable declaration 

C




int *A [10], B [10][10];


Of the following expressions

I.   A [2]
II.  A [2][3]
III. B [1]
IV.  B [2][3] 

which will not give compile-time errors if used as left hand sides of assignment statements in a C program ?

(A)

I, II and IV only

(B)

II, III and IV only

(C)

II and IV only

(D)

IV only



Answer: (A)

Explanation:

A is an array of pointers to int, and B is a 2-D array.

  • A[2]= can take a pointer
  • A[2][3]= can take an int
  • B[1]=B[1] is the base address of the array and it cannot be changed as array in C is a constant pointer.
  • B[2][3]= can take an integer

So, option (A) is the answer.


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads