Atan2() - C library function Program

Declaration :

double atan2(doubly y, double x)

Explanation :

PurposeThe C library function double atan2(doubly y double x) returns the arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant.
Parameters x ===> This is the floating point value representing an x-coordinate.
y ===> This is the floating point value representing an y-coordinate.
Return ValueThis function returns the principal arc tangent of y/x in the interval [-pi+pi] radians.
Exception

C Program : Example

The following example shows the usage of atan2() function.

#include 
#include 
#define PI 3.14159265
int main ()
{
   double x, y, ret, val;
   x = -7.0;
   y = 7.0;
   val = 180.0 / PI;
   ret = atan2 (y,x) * val;
   printf("The arc tangent of x = %lf, y = %lf ", x, y);
   printf("is %lf degrees\n", ret);
   return(0);
}