177 views
1 votes
1 votes

CAN ANYONE EXPLAIN THE WORKING OF THE CODE..??

1 Answer

Best answer
1 votes
1 votes

In Row Major Order to find address of an element

A[0..n][0....m]

to find A[p][q]=BA+[(p-0)*(m-0+1)+(q-0)]*size of element.

Here first find address of A[6][10] and A[6][9].Assume BA=P

A[6][10]= P+(6-0)*30+(10-0)         // size of element=1B.

            =P+180+10

            =P+20*9+10  Compare with given equation i.e) ${\color{Red} P+20*j+i}$

Then j=9 and i=10 the value is derived by right side production i.e) ${\color{Red} i*30+j}$

The value of A[6][10]=10*30+9=309.

II)A[6][9]=P+(6-0)*30+(9-0)

             =P+180+9

             =P+20*9+9

same as above j=9 and i=9

The value is A[6][9]=9*30+9=279.

The value printed by printf is =309-279=30

selected by

Related questions

0 votes
0 votes
0 answers
1
iita asked Nov 28, 2016
368 views
Which of the following information is NOT a part of a typical process control block A) CPU-scheduling informationB) CPU-stack pointer valuesC) CPU- timer informationD) CP...
4 votes
4 votes
1 answer
2
mcjoshi asked Sep 23, 2016
932 views
In a cache organized memory there exist $30$% of compulsory misses, $10$% capacity misses, $12$% conflict misses. If cache is fully associative Find the average access ti...
1 votes
1 votes
1 answer
3
Jason_Roy asked Feb 4, 2017
739 views
Can anyone solve this??Doubts: Branch penalty should be 2. right?and what is the branch penalty for unconditional branch?