atan()

The atan() function returns the inverse tangent of an argument in radians.

Syntax

atan(n)

The n parameter can be any real number (positive, negative, or zero).

  • If n is zero, the result will be zero with the same sign.
  • If n is postive or negative infinity, the result will be 1.5708 radians with the same sign.

Example

The following example uses the atan() function that returns the inverse tangent of value 0.0:

#include <iostream>
#include <cmath>
int main() {
double x = 0.0;
double result;
result = std::atan(x);
std::cout << result << " radians" << "\n";
}

This produces the following output:

0.0 radians

Codebyte Example

The following example returns the inverse tangent of the value with the atan() function:

Code
Output
Loading...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C++ on Codecademy