What is the address of element 6 of a 15element array that s

What is the address of element 6 of a 15-element array that starts at memory location 40 IF the address of the final element (the last one) is 54?

a)54

b) 64

c )45

d) 48

Solution

Dear Student,

If we want to find the address of an array stored in memory location then the formula to find the address is..

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 element whose address is to be found
LB = Lower limit of subscript, if not specified assume 0.

Now in your question size of the element is not specifed so first we find the size of element.So first element is stored in 40 location and last store is stored in 54 memory location.And there are 15 total number of element so here the size of the element is clear, that is 1 byte.

So W= 1 byte;

Lower Limit I = 5; (Because Subscribt will start with A[0]....A[14] for 15 element.So for 6 element subscript will be 5 i.e A[5].)

LB=0;

B = 40 ( Base Address).

Now apply the above formula..

A[I]=B+W*(I-LB)

A[5] = 40+1*(5-0);

A[5]=45 Ans..

So address of 6 of a 15-element array will be 45.

hence the option number C is correct.

Thanks..!!!

What is the address of element 6 of a 15-element array that starts at memory location 40 IF the address of the final element (the last one) is 54? a)54 b) 64 c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site