For each question, give the following three values for the last line of each code block following the execution of the entire block: 1. the memory address which that line writes to, 2. the value that is written to that address, and 3. the number of distinct memory reads required by that line. If you cannot determine the memory address from the information given, enter 0 for th address. When computing the number of memory reads, assume nothing about the value of registers prior to the execution of the last statement: count a read even if the previous line also read (or wrote) the location. Count the number of distinct memory locations read by that statement; that is, if the line reads a memory location multiple times, cour it only once. Assume that memory accesses always succeed, i.e. that all memory addresses are accessible to the program. For example, for the following code block: int *foo (int *)0x1000; int *bar = (int *)0x1000; *foo = 1; *foo=foo + *bar + 1; you would answer address = 0x1000, value = 3 and reads = 3 (one for foo, one for bar, and one for what they point to). Give memory addresses in hex; and values and read counts in decimal. A. // Declarations and Initializations int *b = (int *)0x1000; inth= (int *)0x1004; int i = (int *)0x1008; int j = (int *)0x6000; int *s = (int *)0x100c; int **e=&s; int **g = &b; int **p = &i; int **q = (int **)0x3000; int **z &h; *b = 7; *h = 15; *1 = 10; *s = 16; // set j[0] // set q[0] ... q[9] = [&j [0], &j [1], ... // Unique Code for this Subquestion *b = *(j + 4); q[b] = q + 4; *q [*b] = Address j[9] = [0, 7, 5, 6, 2, 8, 9, 3, 4, 1] , &j[9]] *q[*b] + j[*b] + (&j[6] hex number Value integer Reads integer ? x 0% THE SAME FOR EVERY SUBQUESTI X 0% X 0% &j [4]);

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.1: Addresses And Pointers
Problem 12E
icon
Related questions
Question
For each question, give the following three values for the last line of each code block
following the execution of the entire block:
1. the memory address which that line writes to,
2. the value that is written to that address, and
3. the number of distinct memory reads required by that line.
If you cannot determine the memory address from the information given, enter 0 for the
address.
When computing the number of memory reads, assume nothing about the value of
registers prior to the execution of the last statement: count a read even if the previous
line also read (or wrote) the location. Count the number of distinct memory locations
read by that statement; that is, if the line reads a memory location multiple times, count
it only once. Assume that memory accesses always succeed, i.e. that all memory
addresses are accessible to the program.
For example, for the following code block:
int *foo (int *)0x1000;
int *bar = (int *)0x1000;
*foo = 1;
*foo=foo + *bar + 1;
you would answer address = 0x1000, value = 3 and reads = 3 (one for foo, one for
bar, and one for what they point to).
Give memory addresses in hex; and values and read counts in decimal.
A.
// Declarations and Initializations
int *b = (int *)0x1000;
=
inth (int *)0x1004;
int i = (int *)0x1008;
int j = (int *)0x6000;
int *s = (int *)0x100c;
int **e &s;
=
int **g &b;
=
int **p=&i;
int **q
int **z
*b = 7;
*h = 15;
*i = 10;
= (int **)0x3000;
&h;
=
*s = 16;
// set j[0] -j[9] = [0, 7, 5, 6, 2, 8, 9, 3, 4, 1]
// set q[0] ... q[9] = [&j[0], &j[¹], .
&j [9]]
// Unique Code for this Subquestion
*b = *(j + 4);
q[*b] = q + 4;
*q [*b] = *q [*b] + j[*b] + (&j[6] - &j[4]);
Address hex number
Value integer
Reads integer
?
?
→ × 0%
x
THE SAME FOR EVERY SUBQUESTION
X 0%
x 0%
"
Transcribed Image Text:For each question, give the following three values for the last line of each code block following the execution of the entire block: 1. the memory address which that line writes to, 2. the value that is written to that address, and 3. the number of distinct memory reads required by that line. If you cannot determine the memory address from the information given, enter 0 for the address. When computing the number of memory reads, assume nothing about the value of registers prior to the execution of the last statement: count a read even if the previous line also read (or wrote) the location. Count the number of distinct memory locations read by that statement; that is, if the line reads a memory location multiple times, count it only once. Assume that memory accesses always succeed, i.e. that all memory addresses are accessible to the program. For example, for the following code block: int *foo (int *)0x1000; int *bar = (int *)0x1000; *foo = 1; *foo=foo + *bar + 1; you would answer address = 0x1000, value = 3 and reads = 3 (one for foo, one for bar, and one for what they point to). Give memory addresses in hex; and values and read counts in decimal. A. // Declarations and Initializations int *b = (int *)0x1000; = inth (int *)0x1004; int i = (int *)0x1008; int j = (int *)0x6000; int *s = (int *)0x100c; int **e &s; = int **g &b; = int **p=&i; int **q int **z *b = 7; *h = 15; *i = 10; = (int **)0x3000; &h; = *s = 16; // set j[0] -j[9] = [0, 7, 5, 6, 2, 8, 9, 3, 4, 1] // set q[0] ... q[9] = [&j[0], &j[¹], . &j [9]] // Unique Code for this Subquestion *b = *(j + 4); q[*b] = q + 4; *q [*b] = *q [*b] + j[*b] + (&j[6] - &j[4]); Address hex number Value integer Reads integer ? ? → × 0% x THE SAME FOR EVERY SUBQUESTION X 0% x 0% "
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr