What is the value of each variable a, b, c_ptr at the end of each program. Give
ID: 3881794 • Letter: W
Question
What is the value of each variable a, b, c_ptr at the end of each program. Give N/A if a value is undefined. You should practice drawing a memory map for solving these questions. Assume the following memory locations for the variables Location of a is 0xFFFF FF0O Location of b is 0xFFFF FEOO -Location of c-ptr is 0xFFFF-FD00 a. (3 pts) void main () char a 5; char b = 10; char c_ptr: c-ptr &a; = c ptr-b; c-ptr = &b; b is c ptr is b. (3 pts) void main) char a5; char b10; char *c_ptr 0; (*c ptr)++ c ptr+ti a is b is c_ptr is c. (4 pts) (note all instances of char were changed to int) void main) int a 5; int b = 10; int *c-ptr 0; (*c ptr)++ c ptr+ti b is c_ptr isExplanation / Answer
A) c_ptr = &a means c_ptr is pointing to a i.e 0xFFFF_FE00
0xFFFF_FE00 HAS value 12
0xFFFF_FE00 HAS value 10
c_ptr = &b means c_ptr is pointing to b i.e 0xFFFF_FE00
0xFFFF_FE00 HAS value 10
0xFFFF_FE00 HAS value 5
a = 10, b = 5 and at the end c point to b so its b's address 0xFFFF_FE00
2) a = 5, b = 11 and c = address of b + 1 , so its b's address 0xFFFF_FE001
3) a = 10 + 10 = 20
b = 11
c = address of b + 1 , so its b's address 0xFFFF_FE004
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.