atan2() - Mathematical Function

How is Mathematical Function "atan2()" used in C++?
How to find the arc tangent value of y/x using c++?


atan2() is a Mathematical Function that returns the arc tangent value of y/x in radians. It uses the signs of both arguments "y" and "x" to find the quadrant.


float atan2 ( float y, float x );
double atan2 ( double y, double x );
long double atan2 ( long double y, long double x );

Example :

#include <stdio.h>
#include <math.h>
int main(void)
double x,y, r;
r=atan2(y, x);
printf("The arc tangent of y/x is::%lf ", r);
return 0;

Result :

The arc tangent of y/x is:: 2.677945

In the above example atan2() is used to find the arc tangent value for "2.0/-4.0".

C++ Tutorial

Ask Questions

Ask Question