Table of Contents
What will be the address of the ARR?
Discussion Forum
Que. | What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows and 5 columns and starting address of the array is 2000? |
---|---|
b. | 2056 |
c. | 2052 |
d. | 2042 |
Answer:2052 |
How can you find out the address of a particular index if elements are stored in column major order in a two dimensional array?
By Column major order If array is declared by a[m][n] where m is the number of rows while n is the number of columns, then address of an element a[i][j] of the array stored in row major order is calculated as, Address(a[i][j]) = ((j*m)+i)*Size + BA.
Are is an example of type memory location?
Discussion Forum
Que. | Array is an example of _______ type memory allocation. |
---|---|
b. | Run Time |
c. | Depends on the Compiler |
d. | None of the above |
Answer:Compile Time |
Why a 5 ]= 5 a ]? Explain?
This is the direct artifact of arrays behaving as pointers, “a” is a memory address. The address of this element is “a + 5”. This is equal to offset “a” from “5” elements at the beginning of the address space (5 + a).
Is there any difference in below declarations int fun int arr 5 INT fun int arr?
Is there any difference int the following declarations? Explanation: No, both the statements are same. It is the prototype for the function fun() that accepts one integer array as an parameter and returns an integer value.
Is there any difference in below declarations int fun int arr 5 int fun int arr?
Why does int arr[4] have no value?
By just declaring int arr [4] you are simply creating a reference. Because it is never assigned a value, the values at where this reference points to doesn’t change. This is because C is an explicit language. So the values there are the values of whatever previously held the memory arr [4] is using.
What is the difference between arr[5] and &arr[2] =?
If we have an array[5], we know that arr = &arr[0] but what is &arr[2] =? In a C based language, &arr[0]is a pointer to the first element in the array while &arr[2]is a pointer to the third element in the array.
What is the value of ARR + 1 in 1D array?
So we can say that arr points to the 0 th 1-D array, arr + 1 points to the 1 st 1-D array and arr + 2 points to the 2 nd 1-D array. Since arr + i points to i th element of arr, on dereferencing it will get i th element of arr which is of course a 1-D array.
What is * (* (* (*(arr + i ) + j ) + k) )?
The name of the array arr is a pointer to the 0 th 2-D array. Thus the pointer expression * (* (* (arr + i ) + j ) + k) is equivalent to the subscript expression arr [i] [j] [k]. We know the expression * (arr + i) is equivalent to arr [i] and the expression * (* (arr + i) + j) is equivalent arr [i] [j].