Three dimensional array in c program -



Three dimensional array in c program -

after putting efforts unable solve next question. question asked in graduate aptitude test in engineering science (gate) 2014, india.

question) c programme accessing x[i][j][k], next intermediate code generated compiler. assume size of integer 32 bits , size of character 8 bits.

t0 = * 1024

t1 = j * 32

t2 = k * 4

t3 = t1 + t0

t4 = t3 + t2

t5 = x[t4]

which 1 of next statements source code c programme correct?

(a) x declared "int x[32][32][8]".

(b) x declared "int x[4][1024][32]".

(c) x declared "int x[4][32][8]".

(d) x declared "int x[32][16][2]".

one of book provide solutions previous papers says reply alternative (a). how? explanation

thanks in advance

t1 i * (inumints * sizeof(int)).

so, inumints * 32 = 1024.

thus, inumints = 32.

t1 j * (jnumints * (inumints/sizeof(int)), becasue there 1 j every row of i.

so, jnumints * 1 = 32.

thus, jnumints = 32.

t2 k * (knumints * (inumints/sizeof(int) / ((inumints*jnumints)/sizeof(int)))). (because there 1 i , i rows of j every k)

so, knumints * 1/2 = 4.

thus, knumints = 8.

thus, int x[32][32][8].

c

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -