In: Computer Science
Determine the memory address of A[3], A[10], A[20]
a) given int A[]
b) given short A[]
c) given char A[]
a) int datatype storage size is 4 bytes and consider the memory starts at 0x0000.
Memory address of A[3]:
3*4=12 bytes=0x000C(hexadecimal address)
Hence the memory address of A[3] is 0x000C.
Memory address of A[10]:
10*4=40 bytes=0x0028(hexadecimal address)(2*16+8)
Hence the memory address of A[10] is 0x0028.
Memory address of A[20]:
20*4=80 bytes=0x0050(hexadecimal address)(5*16+0)
Hence the memory address of A[3] is 0x0050.
b) short datatype storage size is 2 bytes and consider the memory starts at 0x0000.
Memory address of A[3]:
3*2=6 bytes=0x0006(hexadecimal address)
Hence the memory address of A[3] is 0x0006.
Memory address of A[10]:
10*2=20 bytes=0x0014(hexadecimal address)(1*16+4)
Hence the memory address of A[10] is 0x0014.
Memory address of A[20]:
20*2=40 bytes=0x0028(hexadecimal address)(2*16+8)
Hence the memory address of A[3] is 0x0028.
c) char datatype storage size is 1 byte and consider the memory starts at 0x0000.
Memory address of A[3]:
3*1=3 bytes=0x0003(hexadecimal address)
Hence the memory address of A[3] is 0x0003.
Memory address of A[10]:
10*1=10 bytes=0x000A(hexadecimal address)
Hence the memory address of A[10] is 0x000A.
Memory address of A[20]:
20*1=20 bytes=0x0014(hexadecimal address)(1*16+4)
Hence the memory address of A[3] is 0x0014.