# atan() function with example in C++

C++ atan() function: Here, we are going to learn about the atan() function with example of cmath header in C++ programming language?
Submitted by IncludeHelp, on April 28, 2019

## C++ atan() function

atan() function is a library function of cmath header, it is used to find the principal value of the arc tangent of the given number, it accepts a number (x) and returns the principal value of the arc tangent of x in radians.

Syntax of atan() function:

```    atan(x);
```

Parameter(s): x – is the value whose arc tangent to be calculated.

Return value: double – it returns double type value that is the principal value of the arc tangent of the given number x.

Example:

```    Input:
float x = 0.65;

Function call:
atan(x);

Output:
0.576375
```

### C++ code to demonstrate the example of atan() function

```// C++ code to demonstrate the example of
// atan() function

#include <iostream>
#include <cmath>
using namespace std;

// main() section
int main()
{
float x;

x = -1.0;
cout<<"atan("<<x<<"): "<<atan(x)<<endl;

x = -0.89;
cout<<"atan("<<x<<"): "<<atan(x)<<endl;

x = 0.65;
cout<<"atan("<<x<<"): "<<atan(x)<<endl;

x = 1;
cout<<"atan("<<x<<"): "<<atan(x)<<endl;

return 0;
}
```

Output

```atan(-1): -0.785398
atan(-0.89): -0.727263
atan(0.65): 0.576375
atan(1): 0.785398
```

Reference: C++ atan() function

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates