184k views
0 votes
Suppose a four-dimensional array has been declared within the scope you are currently executing. You, however, want to refer to information about the size of each dimension not by their values or symbolic constants, but rather by formulas. Using only the sizeof operator and the name of the array, a, write expressions that will yield each of the array dimensions, in left-to-right order, that is:

a. the first dimension (which is the same as the number of 3-dimensional (top-level) elements in the array)
b. the second dimension (which is the number of 2-dimensional elements in each top-level element)
c. the third dimension (the number of 1-dimensional arrays in each 2-d element)
d. the fourth dimension (the number of data items in each 1-dimensional array)

User Fisakhan
by
5.8k points

1 Answer

2 votes

Answer:

A ) Sizeof(arr)/sizeof(arr[0])

B) Sizeof(arr[0])/sizeof(arr[0][0])

C) Sizeof(arr[0][0])/Sizeof(arr[0][0][0])

D) Sizeof(arr[0][0][0])/Sizeof(int)

Step-by-step explanation:

using only the size of operator and the name of the array to write an expression that will yield each of the array Dimensions in left-to-right order

A ) Sizeof(arr)/sizeof(arr[0])

B) Sizeof(arr[0])/sizeof(arr[0][0])

C) Sizeof(arr[0][0])/Sizeof(arr[0][0][0])

D) Sizeof(arr[0][0][0])/Sizeof(int)

attached below is the handwritten copy

Suppose a four-dimensional array has been declared within the scope you are currently-example-1
User Mrmoje
by
5.1k points