in Programming in C
3,150 views
0 votes
0 votes
A is a 2D-array with the range [-5....5,3......13] of elements.The starting location is 100. each element accupies 2 memeory cells.
Calculate the location of A[0][8] using column major order and row major order.Does indexing matter??Why C follow $0$ indexing??
in Programming in C
3.2k views

4 Comments

The basic concept is

range [-5....5,3......13] 

Now make it normal so that execution is easy

-5 to 5 {contains 11 rows }

3 to 13 {contains 11 col}

size of an array A 11 x 11

ranges [0 ....10 , 0 ... 10]

shift from -5 to  0 we add 5 

shift from +3 to 0 subtract  3 

therefore  A[0+5][8-3] 

A[5][5] = 100 + (11*5+5)*2

            = 100 + 60*2

            = 220

similarly we do for col major oder

 

2
2
I understand thank you so much
0
0

@Magma @Lakshman Patel RJIT

i did not understand your solution from the line shift onwards.

Please suggest why did you do like that.

thanks

0
0

1 Answer

0 votes
0 votes
Row major  220 same col major 220

Related questions

2 votes
2 votes
1 answer
3