Question

In: Computer Science

Question 1: As you know that “the base address or the starting address of any array...

Question 1: As you know that “the base address or the starting address of any array is its name”. Keeping this information, answer

a. Why the first index of any array always starts from zero. Although it points to the first location of an array.

b. The reason why the last index is always one less than array length is “the first index starts from zero”. Does it seems to be a correct reason justify.

c. What is the offset address of any array NAMED AS ARR1 who starting address is A011234h.

d Can you find the offset address of the 6th element of array given in 3? If its data type is INT.

e. What is the offset address of last element of an array stated in 3? If the length of array is 5 and data type is char.

Kindly solve the complete Questions with all parts......

Solutions

Expert Solution

Array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created.

Answering a:

As you have said, "the base address or the starting address of any array is its name”. You are right here.

Actually, Array name is a constant pointer, pointing to the base address. When you use arr[i] the compiler manipulates it as *(arr+i). Since int range is -128 to 127,the compiler thinks that -128 to -1 are negative numbers and 0 to 128 are positive numbers.So array index always starts with zero.

Answering b:

As the indexing starts from zero, the last index will be always less than length of the array. For example, when you count number of week days starting from zero with Sunday, you will be ending with 6 for Sunday.

Answering c:

Offset for a memory operand is called, the operand's effective address or EA. It is an unassigned 16 bit number, that expresses the operand's distance in bytes from the beginning of the segment in which it resides.

We know that the base address is A011234h.

So we know that the first element, (offset 0) is at location A011234h. Since arrays must be stored on contiguous bytes, we know that the next element is stored at A011234h+2 ( A011234h + 2 bytes).


Related Solutions

1. An array has an index of [5] at the starting address of 200. It has...
1. An array has an index of [5] at the starting address of 200. It has 3 words per memory cell, determine loc[3],loc[4] and NE. (3 Marks: 1 mark for each) 2. A 2-D array defined as A[10 , 5] requires 4 words of storage space for each element. Calculate the address of A[4,3] given the base address as 250 • If the array is stored in Row-major form • If the array is stored in Column-major form 3. Write...
An array has an index of [5] at the starting address of 200. It has 3...
An array has an index of [5] at the starting address of 200. It has 3 words per memory cell, determine loc[3],loc[4] and NE. (3 Marks: 1 mark for each) A 2-D array defined as A[10 , 5] requires 4 words of storage space for each element. Calculate the address of A[4,3] given the base address as 250 If the array is stored in Row-major form If the array is stored in Column-major form Write a method for the following...
An array has an index of [5] at the starting address of 200. It has 3...
An array has an index of [5] at the starting address of 200. It has 3 words per memory cell, determine loc[3],loc[4] and NE. (3 Marks: 1 mark for each) A 2-D array defined as A[10 , 5] requires 4 words of storage space for each element. Calculate the address of A[4,3] given the base address as 250 If the array is stored in Row-major form If the array is stored in Column-major form Write a method for the following...
Write a procedure to calculate Average of numbers(integers) using Arrays. Send base address of array in...
Write a procedure to calculate Average of numbers(integers) using Arrays. Send base address of array in register $a1 and Array length in register $a2 to the procedure and return Average in register $v0 to main program.
I know this is more than one question. I'm hoping you can address these all at...
I know this is more than one question. I'm hoping you can address these all at once? How are the ways in which organizations choose to measure and evaluate the performance of their segments tied to how managers of those segments get evaluated? What are the ways those approaches can fairly evaluate managers? How can those approaches sometimes unfairly evaluate managers? Can people "game" this system? If so, how? What can be done to ensure both accurate segment performance evaluation...
Use the 74LS138 , to design an address decoder that will place 8K by 16bit RAM at a starting address of C000h and 8K RAM at a starting address of 6000h.
Use the 74LS138 , to design an address decoder that will place 8K by 16bit RAM at a starting address of C000h and 8K RAM at a starting address of 6000h.
Think of a business you may be interested in starting and take the time to address...
Think of a business you may be interested in starting and take the time to address the following questions in detail (please include the question numbers below when you answer each question): 1. What kind of resources would you need to acquire to operate this business? 2. Which costs are implicit costs? 3. Which resources are fixed and which are variable? 4. Explain the difference between fixed and variable costs for this business. 5. Explain how this business could experience...
Think of a business you may be interested in starting and take the time to address...
Think of a business you may be interested in starting and take the time to address the following questions in detail (please include the question numbers below when you answer each question): 1. What kind of resources would you need to acquire to operate this business? 2. Which costs are implicit costs? 3. Which resources are fixed and which are variable? 4. Explain the difference between fixed and variable costs for this business. 5. Explain how this business could experience...
(1) What are the biggest question(s) we need to address in any derivative market? (2) Suppose...
(1) What are the biggest question(s) we need to address in any derivative market? (2) Suppose I am a trader, who buys and holds Japanese Yen. How could I use forward to protect my holding of Japanese Yen?
Question 1 You are trying to value the stock of Cowbell Inc. You know that the...
Question 1 You are trying to value the stock of Cowbell Inc. You know that the firm only uses dividends to return cash to its investors and you have forecasted the dividends for the 4 years (see table below). You believe that dividends will grow at a constant rate of 2% each year after year 4. The cost of equity is 13%. Given this information estimate the share price for Cowbell Inc. Round your answer to two decimals (do not...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT