Question: Pointers Worksheet (C++) Name: ________________________________________________ Create an integer variable called val Create a pointer called p Create a pointer called q Name Value Mem Address
Pointers Worksheet (C++)
Name: ________________________________________________
Create an integer variable called val
Create a pointer called p
Create a pointer called q
| Name |
|
|
|
|
|
|
|
|
|
| Value |
|
|
|
|
|
|
|
|
|
| Mem Address | 100 | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 |
Assign 4 to val
Make p point to val
Make q point to what p points to
| Name |
|
|
|
|
|
|
|
|
|
| Value |
|
|
|
|
|
|
|
|
|
| Mem Address | 100 | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 |
Write code to make val display its address
Write code to make p display the value of the variable it points to
Use p to change the value of val to 10
| Name |
|
|
|
|
|
|
|
|
|
| Value |
|
|
|
|
|
|
|
|
|
| Mem Address | 100 | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 |
Make q point to nothing
Which of the following statements are syntactically correct?
- val = p;
- q = &val;
- *p = val;
- *p = *q;
- *p = &val
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
