Example 2: Conversion from Cartesian to Polar Coordinates

Learn how to convert Cartesian Coordinates (x, y) of a point to its polar coordinates (r, theta).

Problem

In mathematics, a point in a plane can be represented using either the Cartesian Coordinate system or the Polar coordinate system.

Write a function that receives Cartesian Coordinates x and y of a point, and convert them into its polar coordinates r and θ\theta.

Remember to print the result in two decimal places.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.