Example 2: Conversion from Cartesian to Polar Coordinates
Explore how to convert Cartesian coordinates to polar coordinates in C. Understand the mathematical formulas for radius and angle, implement the conversion, and output results with two decimal precision. Learn to work with radians and degrees using standard math functions.
We'll cover the following...
We'll cover the following...
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 .
Remember to print the result in two decimal places.
Example
| Input (x , y) | Output (r , ) |
|---|---|
| 12 , 12 | 16.97 , 45.00 |
| 12 , 5 | 13.00 , 22.62 |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.
Hint: ...