Write a program that prompts the user for the x and y coordinates of a point on the x-y plane, and then displays the position of that point in polar coordinates.
The program must execute via a function ‘polar’ that is called from the main function. This function accepts x & y coordinates as input value parameters, and then returns, through reference parameters, the polar coordinate position of the point (r and theta).
Could in theory be written entirely in the main function; however, to meet the problem statement the code must include a user defined function that returns polar coordinates to the main function via reference parameters.
Some helpful programming hints:
(i) Reference parameters are declared using an ampersand after the declaration type: for example – ‘int& number’ declares a reference parameter ‘number’ of type ‘integer’.
(ii) You’ll need the cmath library for arctan and sqrt functions. The C++ syntax for the arctan function is “atan(x)”.
(iii) The C++ arctan function returns an angle in radians. For output to the screen convert the angle theta from radians to degrees.
(iv) Program should work for x, y values in all four quadrants of the x-y plane.
Also, the C++ complex number library can do polar/cartesian conversions rather simply.
(those are just what jumps at me.. but if your question is how to "include a user defined function that returns polar coordinates to the main function via reference parameters.", I believe you're asked to write a function void polar(double x, double y, double& r, double& theta))