Address Calculation in 1d Array

It is a very important part in array to calculate memory address. Because we can easily recognize the array element. In this tutorial, we discuss address calculation in 1D Array element.

Suppose, In one dimensional array,

int a[5] = {10,20,30,40,50};

The memory representation of this array is

            Actual address 
               in memory =>      1000  1004  1008  1012  1016
          Array Elements =>       10    20    30    40    50
           Address w.r.t 
         Array Subscript =>        0     1     2     3     4

Array of an element of an array say “A[ I ]” is calculated using the following formula:

Address of A [ I ] = B + W * ( I – LB )

Where,
B = Base address.
W = Storage Size of one element stored in the array (in byte).
I = Subscript of an element whose address is to be found.
LB = Lower limit or Lower Bound of subscript, if not specified assume 0 (zero).

Example:

Given the base address of an array B[1400…..1800] as 1020 and size of each element is 2 bytes in the memory. Find the address of B[1700].

Solution:

The given values are: Base address (B) = 1020, LB = 1400, W = 2, I = 1700

Address of A [ I ] = B + W * ( I – LB )

= 1020 + 2 * (1700 – 1400)
= 1020 + 2 * 300
= 1020 + 600
= 1620 [Ans]

If you find any issue and interested to rewrite it then contact us.

Default image
Lingaraj Senapati
Hey There! I am Lingaraj Senapati, the Co-founder of lingarajtechhub.com My skills are Freelance, Web Developer & Designer, Corporate Trainer, Digital Marketer & Youtuber.
Articles: 217

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply