Question: Part 2 : Pointers ( 3 0 marks ) Create a program and set up the variables as shown in the diagram. Complete the following
Part : Pointers marks
Create a program and set up the variables as shown in the diagram. Complete the following steps for the program:
Part A:
Create a function 'setter' with parameters P and a new value k integer The function should follow the pointer and change the integer at the end of the chain to the new value. marks
Call 'setter' in main with mathrmk When it returns, demonstrate that the new value of i was changed hint: print i marks
Create a swap function with parameters A and B The function should swap them such that A now points at B and B now points to A Call this function with AB in main. marks
Call 'setter' with mathrmk
Now print all variables dereferenced to i or j in the following format: marks
Part B: Finally, draw the new diagram for the new variable setup. marks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
