Consider the following C code. Assume that variables are stored in memory starting at location 1000,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following C code. Assume that variables are stored in memory starting at location 1000, in order and with no gaps between variables. Assume all int's and pointers consume 4 bytes each. a. Show the memory layout and values for the variables at position A. b. Show the memory layout and values for the variables at position B. c. Show the memory layout and values for the variables at position C. d. What is printed by the program? #include int main () { } int x = 2, y = -1; int *p=&x; int *q=&y; int a [3] = (1, 4, 9); // ## A ## *q += 1; 9--; *q += 2; // ## B ## q=&a [1]; *q = 2; p = q++; *p = 0; *q = 3; // ## C ## printf ("%d %d %d ", &p, p, *p); printf ("%d %d %d ", &q, q, *q); Consider the following C code. Assume that variables are stored in memory starting at location 1000, in order and with no gaps between variables. Assume all int's and pointers consume 4 bytes each. a. Show the memory layout and values for the variables at position A. b. Show the memory layout and values for the variables at position B. c. Show the memory layout and values for the variables at position C. d. What is printed by the program? #include int main () { } int x = 2, y = -1; int *p=&x; int *q=&y; int a [3] = (1, 4, 9); // ## A ## *q += 1; 9--; *q += 2; // ## B ## q=&a [1]; *q = 2; p = q++; *p = 0; *q = 3; // ## C ## printf ("%d %d %d ", &p, p, *p); printf ("%d %d %d ", &q, q, *q);
Expert Answer:
Answer rating: 100% (QA)
Based on the provided C code we can work out the memory layout and values for each of the indicated positions A B and C as well as determine what the ... View the full answer
Related Book For
Computer organization and architecture designing for performance
ISBN: 978-0136073734
8th edition
Authors: william stallings
Posted Date:
Students also viewed these programming questions
-
In Exercises 514, an objective function and a system of linear inequalities representing constraints are given. a. Graph the system of inequalities representing the constraints. b. Find the value of...
-
What is a function calling convention and how does it impact the design of the RISC-V instruction set architecture (ISA)? [4 marks] (d) Consider the following C function that computes the greatest...
-
A box is 4 in. high. Its length is I.5 times its width. The volume of the box is 1350 in. 2 . What are the width and length of the box? 2 answers
-
Although offspring typically resemble their parents in many ways, it is also possible for a child to differ from both of her parents in some trait. Think of at least three possible explanations for...
-
The circuit representation in the chapter is more detailed than necessary if we care only about Circuit functionality. A simpler formulation describes any rn-input, n-output gate or circuit using a...
-
Companies regularly review the locations where they offshore activities to and the associated costs. Some decide to reshore or nearshore. Referring to the world map at the start of the book, how do...
-
At what time is it proper to recognize income in the following cases? (a) Installment sales with no reasonable basis for estimating the degree of Collectibility? (b) Sales for future delivery? (c)...
-
Discussion questions: With reference to the reading explain what Wolf means by a sane deep self. Do you think that Jojo is morally responsible (viz., deserving of praise and blame for his actions)?...
-
Analyze whether counseling for weight reduction has a significant effect on reducing blood pressure? Hypertension Some common strategies for treating hypertensive patients by nonpharmacologic methods...
-
One of the partners at your firm has asked you to develop an office training report to familiarize your audit team with sampling models that can be used for auditing monetary balances. The partner...
-
How does Conflict theory critique mainstream approaches to social order and stability, emphasizing instead the role of conflict as a driving force in shaping social relations and institutions?
-
Determine: (1) the break-even in units and dollars, (2) explain what the calculated contribution margin means for this company, (3) what is the expected margin of safety in dollars and as a percentage
-
Along that train of thought, craft Reflection Analysis paper addressing the following: What were your initial course goals?( my primary goal for this term is to gain a comprehensive and nuanced...
-
12. List the indexes for characterizing the coarse aggregate abrasion resistance, surface texture of fine aggregate, and clay content of fine aggregate. Describe whether a larger or smaller value for...
-
Briefly define and explain what is information asymmetry? 2) What specific problems arise from information asymmetry? Please list and explain them in the context of investing in the stock market. 3)...
-
1. Discuss where in an organization you will find Knowledge Wells 2. Define Knowledge Management and what you think it is and ought to be?
-
Use multiplication or division of power series to find the first three nonzero terms in the Maclaurin series for each function. y = e x2 cos x
-
a. Identify the write-read, write-write, and read-write dependencies in the following instruction sequence: b. Rename the registers from part (a) to prevent dependency problems. Identify references...
-
A 32-bit computer has two selector channels and one multiplexor channel. Each selector channel supports two magnetic disk and two magnetic tape units. The multiplexor channel has two line printers,...
-
For a direct-mapped cache, a main memory address is viewed as consisting of three fields. List and define the three fields.
-
Donna Corporation manufactures custom cabinets for kitchens. It uses a normalcosting system with two direct-cost categoriesdirect materials and direct manufacturing laborand one indirect-cost pool,...
-
Donna Corporation manufactures custom cabinets for kitchens. It uses a normalcosting system with two direct-cost categoriesdirect materials and direct manufacturing laborand one indirect-cost pool,...
-
Donna Corporation manufactures custom cabinets for kitchens. It uses a normalcosting system with two direct-cost categoriesdirect materials and direct manufacturing laborand one indirect-cost pool,...
Study smarter with the SolutionInn App