atan2 function calculates the arc tangent of a/b

Syntax

C atan2 function has the following syntax.

  • float atan2f(float a, float b);
  • double atan2(double a, double b);
  • long double atan2l(long double a, long double b);

C atan2 functions are from header file math.h.

Description

C atan2 function returns the arc tangent of a/b.

Example

The following code shows how to calculate the arc tangent of a/b.


#include <math.h>
#include <stdio.h>
//from ww w . j  av  a2 s .  c om
int main(void)
{
  double val = -1.0;

  do {
    printf("Atan2 of %f is %f.\n", val, atan2(val,1.0));
    val += 0.1;
  } while(val<=1.0);

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h