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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started