915 views
0 votes
0 votes

Suppose we have an array with base address 2000. Each element of the array occupies 2 bytes. And we want to fetch the first 8 bits of the first element of the array. What will it return?

More precisely I want to know what is stored in memory location 2000 to 2001  are stored in binary in the array?

400 401 402 403 404

 

1 Answer

0 votes
0 votes

I have assumed that the processor is using Little Endian mode. For Big Endian processors the memory will be reversed.

400 can be written in binary as 

256 128 64 32 16 8 4 2 1

  1    1    0    0   1 0 0  0 0

So, 2000 to 2001 will contain 10010000

      2001 to 2002 will contain 00000001

     and 2002 to 2003  , and 2003 to 2004 will contain all 0's

In Big Endian  processors , these assignments will be reversed ,i.e , 2000 to 2001 will have all 0's

 

For More examples --->

https://www.quora.com/How-is-an-integer-value-stored-in-the-memory-in-C

 

edited by

Related questions

1 votes
1 votes
0 answers
1
piyush512 asked 3 days ago
53 views
Consider an integer upper triangular 2D array arr[–8 to +7][–8 to +7] having base address 1000. If the size of the integer is 4 bytes, the address of the element pres...
1 votes
1 votes
1 answer
2