Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Assume the following C variable declaration
    int* A [10], B [10] [10];
    Of the following expressions which will not give compile time errors if used as left hand sides of assignment statements in a C program ?
    (i) A [2]
    (ii) A [2] [3]
    (iii) B [1]
    (iv) B [2] [3]
    1. I, II and IV only
    2. II, III and IV only
    3. II, and IV only
    4. IV only
Correct Option: A

A is an array of pointers to int, and B is a 2D array
* A [2] = Can take a pointer
* A [2] [3] = Can take an Int
* B [1] = It is the base address of array and it cannot be changed, as array in C is a Constant pointer. We can not make B the point some other array. So this is false.
* B[2][3] = It can take an integer.
So, option (a) is correct.



Your comments will be displayed only after manual approval.