Question: Reason about why your code works. Do this by drawing a pointer diagram that shows the state of memory right before the initPoint function returns
Reason about why your code works. Do this by drawing a pointer diagram that shows the state of memory right before the initPoint function returns when it is called for the very first time by the test code. Your pointer diagram should show the value of member variables x and y of the struct object p1 in initPointTest.cpp as well as the relationship between p1 and the formal parameter p of the function initPoint. You should also show the formal parameters xVal and yVal in memory and indicate whether or not they are colocated in memory with any other variables (such as x and y). Make the drawing on a piece of paper or as ascii art in a text file and upload it to your gitrepo with the filename: pointer-diagram-initPoint. The diagram will be graded manually by us.
initPointTest.cpp:

Working Code for initPoint function:

Sucess when initPoint function passes ./initPointTest

include #include #include "shapes.h" "shapeFuncs.h" "tddFuncs.h" int main(O struct Point p1,p2,p3,p4 struct Point p1Expected, p2Expected, p3Expected, p4Expected; initPoint(&p1,3.0,4.0); p1Expected.x=3.0; p1Expected.y=4.0; assertTrue (pointsApproxEqual (p1,p1Expected), "pointsApproxEqual(p1, p1Expected)N initPoint(&p2,-1.2,-3.4); p2Expected.x =-1.2; p2Expected.y =-3.4; assertTrue (pointsApproxEqual (p2,p2Expected), "pointsApproxEqual(p2, p2Expected initPoint(&p3 , e.e,e.e); p3Expected.x=0.0; p3Expected.y=0.0; assertTrue (pointsApproxEqual p3,p3Expected), "pointsApproxEqual(p3, p3Expected)N intPoint(&p4 , 0 . 5,-0 . 6 ) ; p4Expected.x=0.5. p4Expected.y=-9.6; assertTrue (pointsApproxEqual(p4, p4Expected), "pointsApproxEqual(p4, p4Expected return 9 include #include #include "shapes.h" "shapeFuncs.h" "tddFuncs.h" int main(O struct Point p1,p2,p3,p4 struct Point p1Expected, p2Expected, p3Expected, p4Expected; initPoint(&p1,3.0,4.0); p1Expected.x=3.0; p1Expected.y=4.0; assertTrue (pointsApproxEqual (p1,p1Expected), "pointsApproxEqual(p1, p1Expected)N initPoint(&p2,-1.2,-3.4); p2Expected.x =-1.2; p2Expected.y =-3.4; assertTrue (pointsApproxEqual (p2,p2Expected), "pointsApproxEqual(p2, p2Expected initPoint(&p3 , e.e,e.e); p3Expected.x=0.0; p3Expected.y=0.0; assertTrue (pointsApproxEqual p3,p3Expected), "pointsApproxEqual(p3, p3Expected)N intPoint(&p4 , 0 . 5,-0 . 6 ) ; p4Expected.x=0.5. p4Expected.y=-9.6; assertTrue (pointsApproxEqual(p4, p4Expected), "pointsApproxEqual(p4, p4Expected return 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
