Question: Question 3: Pointers (10 pt) What is the value of a, b, c_ptr at the end of each program. Give N/A if a value is

Question 3: Pointers (10 pt)

What is the value of a, b, c_ptr at the end of each program. Give N/A if a value is undefined. It is recommended that you practices drawing a memory map for solving these questions.

Assume the following memory locations for the variables:

- Location of a is 0xFFFF_FF00

- Location of b is 0xFFFF_FE00

- Location of c_ptr is 0xFFFF_FD00

a. 3pts

void main()

{

char a = 5;

char b = 10;

char *c_ptr;

c_ptr = &a;

*c_ptr = 12;

*c_ptr = b;

c_ptr = &b;

*c_ptr = a;

}

a is ______ b is __________ c_ptr is ___________ .

b. 3pts

void main()

{

char a = 5;

char b = 10;

char *c_ptr = 0;

c_ptr = &a;

c_ptr = &b;

(*c_ptr)++;

c_ptr++;

}

a is ______ b is _____ c_ptr is ________

c. 4pts (note all variables were changed from chars to ints or pointers to ints).

void main()

{

int a = 5;

int b = 10;

int *c_ptr = 0;

c_ptr = &b;

a = *c_ptr + b;

(*c_ptr)++;

c_ptr++;

}

a is ________ b is _________ c_ptr is ________

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!