5,240 views
0 votes
0 votes
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?
 
I, II, and IV only
B
II, III, and IV only
C
II and IV only
 
IV only

1 Answer

1 votes
1 votes
int *A[10] can be pronounced as, A is a array of 10 pointers to integers,

that means A can store 10 integer pointers, A is like a 2D matrix with 10 rows, but length of each row may differ

on other hand, int B[10][10] , B is matrix of 10 row x10 column

now lets talk about options,

1, A[2] = ***

   here you can assign, address of integer variable to A[2] pointer or you can assign address of integer array to A[2], so this is TRUE

2. A[2][3] = integer_value

   this is extension to 1, here we are assigning value to 3rd location of of array which is pointed by A[2]

A[0] ->

A[1] ->

A[2] -> [2,3,4,5,6,7]  ,          so this is TRUE

 

3. B[1] = ***

    once you declare like, int B[2][3], B becomes a constant pointer, we can not make B to point some other array

    thats the reason we use pointer, like int *A[3]   this gives us flexibility

    so this is false

4. B[2][3] = value

       this is true, because we are just assigning value to memory location in 2D array

so 1,2,4 are true, hence option A

Related questions

2 votes
2 votes
3 answers
2
Laahithyaa VS asked Sep 9, 2023
951 views
. What will be the value returned by the following function, when it is called with 11?recur (int num){if ((num / 2)! = 0 ) return (recur (num/2) *10+num%2);else return 1...
0 votes
0 votes
1 answer
3