English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

C library function atan() usage and example

C Standard Library <math.h>

The atan() function calculates the arctangent of the parameter.

C atan() function prototype

double atan(double x);

The atan() function takes a single double x as a parameter and returns the value in radians.

The type of the value returned by atan() is double.

To better understand atan():

[Mathematics] tan-1x = atan(x) [In C programming]

It is<math.h>Defined in the header file.

C atan() range

The library function atan() takes any value from negative to positive.

Example: C atan() function

#include <stdio.h>
#include <math.h>
#define PI 3.141592654
int main()
{
    double num = 1.0;
    double result;
    result = atan(num);
    printf("tan(%.2f) The arctangent is = %.2f "radians", num, result);
    //Convert radians to degrees
    result = (result * 180)} / PI;
    printf("\ntan(%2f) The arctangent is = %.2f "degree", num, result);
    return 0;
}

Output Result

cos(1The arctangent of (0.00) is = 0.79 radians
cos(1The arctangent of (0.00) is = 45 degree

C Standard Library <math.h>