8.6: Exercises
- Page ID
- 35840
Exercise \(\PageIndex{1}\)
Declare a pointer to a floating point variable, naming it fptr
.
Exercise \(\PageIndex{2}\)
Declare a pointer to a signed character variable, naming it cptr
.
Exercise \(\PageIndex{3}\)
Consider the following snippet of code:
unsigned char c, *p;
Explain the difference between c
and p
.
Exercise \(\PageIndex{4}\)
Consider the following snippet of code:
unsigned char *p; double *p2;
Assume that the value of p
is currently 1000 and the value of p2
is 2000. What are their values after the following piece of code is executed?
p++; p2++;
Exercise \(\PageIndex{5}\)
Explain the difference between the *
and &
operators in relation to pointers.
Exercise \(\PageIndex{6}\)
Consider the line of code below.
a = b*c;
Is the *
operator a pointer dereference or a multiply? How do we know?
Exercise \(\PageIndex{7}\)
Consider the line of code below.
a = b**c;
What do you think this line does? How might you alter this line to mark the intent more clearly and less prone to error or misinterpretation?
Exercise \(\PageIndex{8}\)
Explain the difference between the two lines of code below.
a*=b; a=*b;