Question: Task B. Farther from the origin? In the same file 3d-space.cpp, add a function Coord3D * fartherFromOrigin(Coord3D * p1, Coord3D * p2); Which receives the

Task B. Farther from the origin?

In the same file 3d-space.cpp, add a function

Coord3D * fartherFromOrigin(Coord3D *p1, Coord3D *p2); 

Which receives the coordinates of two points (passed as pointers), and returns the pointer of the point that is farther away from the origin.

A usage example:

int main() { Coord3D pointP = {10, 20, 30}; Coord3D pointQ = {-20, 21, -22}; cout << "Address of P: " << &pointP << endl; cout << "Address of Q: " << &pointQ << endl << endl; Coord3D * ans = fartherFromOrigin(&pointP, &pointQ); cout << "ans = " << ans << endl; // So which point is farther? } 

When testing your code, look at the reported address of the answer ans and determine whether it reports P or Q. You can use a calculator or WolframAlpha) to check the numbers. Try other coordinates of points P and Q to confirm that the program works.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!