Question: 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
Given the C code provided and the memory layout assumptions a Memory layout and values at position A ... View full answer
Get step-by-step solutions from verified subject matter experts
