C Standard Library

C <math.h> - atan() Function



The C <math.h> atan() function returns arc tangent of a value. The returned value will be in the range -𝜋/2 through 𝜋/2.

Note: atan() is the inverse of tan().

Syntax

double atan (double x);
float atanf (float x);
long double atanl (long double x);

Parameters

x Specify the value.

Return Value

Returns the arc tangent of the value.

Example:

In the example below, atan() function is used to find out the arc tangent of a given value.

#include <stdio.h>
#include <math.h>
 
int main (){
  printf("%lf\n",atan(0.5));
  printf("%lf\n",atan(1));
  printf("%lf\n",atan(2));
  return 0;
}

The output of the above code will be:

0.463648
0.785398
1.107149

❮ C <math.h> Library