Popular Tutorials
Start Learning CCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
C tan()
The tan() function returns tangent of the argument passed.
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?