Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following C code. Assume that variables are stored in memory starting at location 1000, in order and with no gaps between variables.

 

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);

Step by Step Solution

3.38 Rating (145 Votes )

There are 3 Steps involved in it

Step: 1

Given the C code provided and the memory layout assumptions a Memory layout and values at position A ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer organization and architecture designing for performance

Authors: william stallings

8th edition

136073735, 978-0136073734

More Books

Students also viewed these Programming questions