This lab is due by Friday, September 26, 2025, Before Class.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.
Jump To: · Rubric · Submission ·
The goal of this lab is to gain
familiarity with using the concepts of pointers and addresses. Complete the following steps inside your main().
This lab will only be working with pointers on the stack.
- Declare two integers named
iNumandiNum2with initial values4and5respectively. - Declare two pointers to integers named
pINum1andpINum2both with initial valuenullptr. - Assign the address of
iNumtopINum1. - Assign the address of
iNum2topINum2. - Output the address of
iNumand be sure to identify to the user what you are displaying. There are two ways you can do this; you should do both, to convince yourself they are the same. - Output the address of
iNum2and be sure to identify to the user what you are displaying. There are two ways you can do this; you should do both, to convince yourself they are the same. - Use
pINum1to display the value ofiNum. - Use
pINum2to display the value ofiNum2. - Directly change the value of
iNumto6. - Use
iNumto output the value ofiNum. - Use
pINum1to output the value ofiNum. - Use
pINum1to change the value it is pointing at to7. - Use
iNumto output the value ofiNum. - Assign
pINum2to have the same value aspINum1. Do not referenceiNum; instead use the address stored inpINum1. - Output the value of
pINum2. This should be the same as displayed in step 5. - Output the value pointed to by
pINum2. - Using
pINum2, change the value it is pointing at to8. - Output the value of
iNumthree times, first usingpINum1, then usingpINum2, theniNumdirectly. In each case, identify what the user is seeing appropriately. - Output the value of
iNum2. It should remain unchanged from the initial value. - Declare a pointer to a double named
pDNumwith initial valuenullptr. - Try to assign the address of
iNumtopDNum. Compile your program. What error message do you see? Comment out this bad line of code, but include the error message as a comment with this line. - Try to assign the value of
pINum1topDNum. Compile your program. What error message do you see? Comment out this bad line of code, but include the error message as a comment with this line. - Declare a double named
dNumwith initial value14.25. - Assign the address of
dNumtopDNum. - Output the address and then the value of
dNumusingpDNumfor both. - Try to assign the value
pINum1is pointing at to the valuepDNumis pointing at. - Output the value of
dNumtwo times, first usingdNumthen usingpDNum.
Grading Rubric
Your submission will be graded according to the following rubric:
| Points | Requirement Description |
| 0.70 | Fully meets specifications |
| 0.15 | Submitted correctly by Friday, September 26, 2025, Before Class |
| 0.15 | Best Practices and Style Guide followed |
| 1.00 | Total Points |
Lab Submission
Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.
Zip together your main.cpp, Makefile file(s) and name the zip file L2B_USERNAME.zip. Upload this zip file to Canvas under L2B.
This lab is due by Friday, September 26, 2025, Before Class.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.