Easy Tutorial
❮ C Examples Lcm C Standard Library Stdlib H ❯

C Library Function - atan()

C Standard Library - <math.h>

Description

The C library function double atan(double x) returns the arctangent of x in radians.

Declaration

Below is the declaration for the atan() function.

double atan(double x)

Parameters

Return Value

This function returns the arctangent of x in radians, within the range [-pi/2, +pi/2].

Example

The following example demonstrates the use of the atan() function.

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

#define PI 3.14159265

int main ()
{
   double x, ret, val;
   x = 1.0;
   val = 180.0 / PI;

   ret = atan (x) * val;
   printf("%lf 的反正切是 %lf 度", x, ret);

   return(0);
}

Let's compile and run the above program, which will produce the following result:

1.000000 的反正切是 45.000000 度

C Standard Library - <math.h>

❮ C Examples Lcm C Standard Library Stdlib H ❯