C++ atan()

Last Updated On Thursday 21st Apr 2022

atan

The C++ atan() function returns the inverse tangent of an angle in radian.It is defined in <cmath> header file.

Syntax

	atan(x)
	

Parameters

The atan() function takes a one argument. It can be positive, negative, or zero.

Return value

The atan() function returns the value in the range of [-π/2, π/2].

atan() prototype [As of C++ 11 standard]

	double atan(double x);
float atan(float x);
long double atan(long double x);
double atan (T x); // For integral type
	

arc tan

Example 1: C++ atan()

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

#define PI 3.14159265

int main () {
  double param, result;
  param = 4.4;
  result = atan(param) * 180 / PI;
  printf ("The arc tangent of %f is %f degrees\n", param, result );
  return 0;
}
	

Output

	The arc tangent of 4.400000 is 77.195734 degrees
	

atan function

Example 2

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

#define PI 3.14159265

int main () {
  double param, result;
  param = 0.1;
  result = atan(param) * 180 / PI;
  printf ("The arc tangent of %f is %f degrees\n", param, result );
  return 0;
}
	

Output

	The arc tangent of 0.100000 is 5.710593 degrees
	

References