Question

3. Suppose that an array of size 5 is declared, of type integer (4 bytes).

int theArray[5];

Also, suppose that the computer assigns the memory address 3152 to the variable at index 0.

Explain how the computer would access theArray[2], and what the memory address would be. Draw diagrams as necessary.

Following are example question and answer:

Suppose that an array of size 5 is declared, of type double (8 bytes). double theArray[5]; Also, suppose that the computer as

8 by te. Given size is Address [i] = Bare address & 8*1 of the Array addrey g the Arrey 3) - 2100+ 8*3 2124 0 1 2 3 4 t index

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Size of Given, integer zu bytes int the Assay [s]; We know that, Address of the Amay [i] = Base Addres +4²i [! Here base addr

Here the computer calculates the address of the accessing element using the formula.
The base address of the array + datatype size * (index of the element).
Here datatype size is 4 bytes and base address is 3152.
So the needed address of theArray[2] = 3152 + 4*2 = 3160.


Please do comment for any queries.
PLease like it.
Thank You.

Add a comment
Know the answer?
Add Answer to:
3. Suppose that an array of size 5 is declared, of type integer (4 bytes). int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 3: Consider a 32-bit physical address memory system with block size 16 bytes and a...

    Question 3: Consider a 32-bit physical address memory system with block size 16 bytes and a 32 blocks direct mapped cache. The cache is initially empty. The following decimal memory addresses are referenced 1020, 1006, 1022, 5106, 994, and 2019 Map the addresses to cache blocks and indicate whether hit or miss. Note: You must use the hexadecimal approach in solving this question. You must also show the computations of dividing the memory address into tag bits, cache index bits,...

  • the coding language is in c++ An array named testScores has already been declared. -size= 5...

    the coding language is in c++ An array named testScores has already been declared. -size= 5 -data type = float - the array has already been initialized these values: 77, 88.5, 90, 93, 71.5 -Write one statement to declare a pointer named: ptr - in the same statement, assign the address to the testScores array to the pointer -write one statement to output the memory address of the array element at testScores[0] -Write a for loop to output the values...

  • please answer $5 UXIF map in the computer uses direct mapping Question 18 5 pts Suppose...

    please answer $5 UXIF map in the computer uses direct mapping Question 18 5 pts Suppose we have a byte-addressable computer using 2-way set associative mapping with 16-bit main memory addresses and 32 blocks of cache. Suppose also that each block contains 8 bytes. The size of the block offset field is bits, the bits. size of the set field is bits, and the size of the tag field is 5 pts Question 19 Suppose we have a byte-addressable computer...

  • Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index...

    Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code. Consider the declaration: int v[1]; What is the index of the last element of this array? Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the...

  • For a given computer system, the main memory is 256Mbyte; word size is 4 bytes; block...

    For a given computer system, the main memory is 256Mbyte; word size is 4 bytes; block size is 64 bytes; cache size is 64 Kbytes. what is the number of cache line? Question 3 options: A 64Kbyte/4bytes B 256Mbyte/4bytes C 256Mbyte/64bytes D 64Kbyte/64bytes Question 4 (3 points) Consider a magnetic disk drive with 8 double sided platters, 2000 tracks per disk surface. Each track has a capacity 2048 KBytes. Sector size is 2KBytes. What is the capacity of acylinder? Question...

  • 6) Paging [26 pts] Suppose you have a computer system with a 38-bit logical address, page size of 16K, and 4 bytes per...

    6) Paging [26 pts] Suppose you have a computer system with a 38-bit logical address, page size of 16K, and 4 bytes per page table entry a) How many pages are there in the logical address space? Suppose we use two level paging and each page table can fit completely in a frame. [4 pts] How many pages? [2 pts] Show your calculations here: b) For the above-mentioned system, give the breakup of logical address bits clearly indicating number of...

  • Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array...

    Define a two-dimensional int array which has 5 rows and 3 columns. The elements in array is randomly initialized (using Math.random()). Write a method to find the maximum value in this two dimensional array; Write a method to find the average value in the array; Write a method to count how many elements are smaller than average; Write a method to copy contents in a two-dimensional array to a one-dimensional array. The method will return this one-dimensional array. Method is...

  • What does this function do? int mystery(double employees[], double id, int size) { for (int i...

    What does this function do? int mystery(double employees[], double id, int size) { for (int i = 0; i < size; i++) { if (id == employees[i]) { return i; } } return -1; } A. This is a function that performs a search. If the id is found in the employees array, its index location is returned, otherwise -1 is returned. B. This is a function that sorts the employees array C. This is a function that returns all...

  • Q1. Suppose we have a virtual memory of size 2 Terabytes (2048GB, or 241 bytes), where...

    Q1. Suppose we have a virtual memory of size 2 Terabytes (2048GB, or 241 bytes), where pages are 8KB (213 bytes) each, and the machine has 4GB (232 bytes) of physical memory.                      a) Compute the number of page table entries needed if all the pages are being used.                       b) Compute the size of the page table if each page table entry also required 4 additional bits (valid, protection, dirty, use). Q2. For this problem, you are given a...

  • Please help me out.. A and C Question. 5. (30 points) Consider a computer with byte...

    Please help me out.. A and C Question. 5. (30 points) Consider a computer with byte addressable main memory bytes, and the block size is 8 bytes. Assume that a direct mapping cache consisting 32 lines is used with this machine. (a) (5 points) How many bits are required to hold a memory address? (b) (5 points) How many total bytes of memory can be stored in the cache? 256 bytes (C) (10 points) How is that memory address divided...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT