C tan()

Function Prototype of tan()

double tan(double x)

The tan() function returns tangent of a number (angle in radians).

[Mathematics] tanx = tan(x) [In C Programming]

It is defined in math.h header file.


Example: C tan() function

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

int main()
{
    double x;
    double result;

    x = 2.3;
    result = tan(x);
    printf("tan(%.2lf) = %.2lf\n", x, result);

    x = -2.3;
    result = tan(x);
    printf("tan(%.2lf) = %.2lf\n", x, result);

    x = 0;
    result = tan(x);
    printf("tan(%.2lf) = %.2lf\n", x, result);

    return 0;
}

Output

tan(2.30) = -1.12
tan(-2.30) = 1.12
tan(0.00) = 0.00
Did you find this article helpful?

Our premium learning platform, created with over a decade of experience and thousands of feedbacks.

Learn and improve your coding skills like never before.

Try Programiz PRO
  • Interactive Courses
  • Certificates
  • AI Help
  • 2000+ Challenges