Given the following C code declaration, struct S1 { int a[ 4 ]; }; struct tElement { int *pInt; struct tS1 S1; int

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Given the following C code declaration, struct S1 { int a[ 4 ]; }; struct tElement { int *pInt; struct tS1 S1; int

Post by answerhappygod »

Given the following C codedeclaration,
struct S1{ int a[ 4 ];};struct tElement{ int *pInt; struct tS1 S1; int m, n;};int i, j;int *pi;struct tElement E[ 2 ];struct tElement *pE;int k[ 2 ];struct tElement N;
Variable allocation is sequential and contiguous startingat 1000. Integers are 4 Bytes and Addresses are 8 Bytes.
The initial value of each variable is equal to its address.(i.e., the variable starting ataddress 1000 equals 1000 thevariable ataddress 1004 equals 1004 etc...)
Furthermore, the memory is re-initialized tothese values before each instruction is run. (i.e.,the instructions are not run sequentially, but independent of eachother.)
Give the address for the following variables: &i=
&E[ 0 ].S1.a[ 0 ] =
&E[ 0 ].n=
&E[ 1 ].S1.a[ 3 ] =
&N.n=
Give the address which changes, and the new value at thataddress, for each of the statements executed.
N.n = *(k -4); Address________ changes to __________ pi = &E[ 0 ].S1.a[ 1 ] +9; Address________ changes to __________ E[ 0 ].S1.a[ -4 ] = (long)(&E -4); Address ________ changesto __________ *(pi - 2) = pE->S1.a[ -1 ]; Address ________ changesto __________ (*(pE+1)).S1.a[ 0 ] = (E + 1)->pInt + 1; Address ________ changesto __________
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply