

#include <math.h> double atan2(double y, double x);
atan2 computes the angle defined by the positive x axis and a line
through the point (x,y) to the point (0, 0). The signs of both values
x and y are used to determine the quadrant of the result in a
Cartesian system. The result is the inverse trigonometric tangent of
y/x if x is not 0.
x,y. The return value is a double-precision,
floating-point number expressed in radians and lies in the half-open interval
(- pi , pi]. For input values (0.0, y), the return value will
be either pi/2 or -pi/2 if y does not equal 0.
x and y are 0, an error message is written to stderr
and the function returns 0.0.
If an error occurs in atan2, the _matherr routine is called.
You can supply your own version of _matherr to suppress the diagnostic
message or modify the value returned.
#include <stdio.h>
#include <lcmath.h>
main()
{
double x, y; /* rectangular coordinates (x,y) */
double r, angle; /* polar coordinates (r,angle) */
puts("Enter the rectangular coordinates please: ");
scanf("%lf %lf", &x, &y );
r = sqrt((x*x) + (y*y));
/* Compute polar coordinates (radians). */
angle = atan2(y , x);
/* Convert radians to degrees. */
angle = (180.0 * angle)/M_PI;
printf("rect coords(%f,%f) -> polar coords(%f,%f)n",
x,y,r,angle);
}
atan, _matherr
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.