# C Program to Convert Cartesian Coordinates to Polar Coordinate

In mathematics, a Cartesian coordinate system is a coordinate system that specifies each point uniquely in a plane by a set of numeric points.

Cartesian Coordinates is represented by (x,y).

In mathematics, the polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference point known as radius and an angle from a reference direction known as theta or simply angle.

Polar Coordinates system is represented by (r,θ).

## Formula to Convert Cartesian Coordinates to Polar Coordinate

To convert from Cartesian Coordinates (x,y) to Polar Coordinates (r,θ):
r = √ ( x2 + y2 )
θ = tan-1 ( y / x )

## Cartesian to Polar C Program

``````
#include<stdio.h>
#include<conio.h>
#include<math.h>

#define PI 3.141592

int main()
{
float x, y, r, theta;
clrscr();
printf("Enter cartesian coordinate x: ");
scanf("%f", &x);
printf("Enter cartesian coordinate y: ");
scanf("%f", &y);

/* Calculating r */
r = sqrt(x*x + y*y);

/* Calculating theta in radian */
theta = atan(y/x);

/* Converting theta from degree to radian */
theta = 180.0 * theta/ PI;

printf("Polar coordinate is: r = %0.2f and theta = %0.2f in degree", r, theta);
getch(); /* Holds Screen */

return(0);
}
``````

Output of the above program :

```Enter cartesian coordinate x: 1 ↲
Enter cartesian coordinate y: 1 ↲
Polar coordinate is: r = 1.41 and theta = 45.00 in degree

Note: ↲ indicates ENTER is pressed.
```