The function double tan(double x); returns the tangent of x, expressed in radians.
Function prototype of tan
double tan(double x);
- x : A floating point value representing an angle in radians.
Return value of tan
It returns the tangent of x.
C program using tan function
The following program shows the use of tan function to calculate tangent of a radian.
#include <stdio.h> #include <math.h> #define PI 3.14159265 int main(){ double value, radian, degree; printf("Enter an angle in degree\n"); scanf("%lf", °ree); /* * Degree to radian conversion * One degree is equal to PI/180 radians. * Where PI = 22/7 = 3.14159(approx) */ radian = degree * (PI/180.0); value = tan(radian); printf("The tangent of %lf is %lf\n", degree, value); return 0; }
Output
Enter an angle in degree 45 The tangent of 45.000000 is 1.000000
Enter an angle in degree 60 The tangent of 60.000000 is 1.732051