tan() Function in C Last Updated : 26 Jun, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report tan() function in C programming is provided by the math.h header file and it is used to calculate the tangent of an angle x where x is represented in radians. This function returns the tangent of a given angle value in radians and it only works for right-angled triangles. Syntax of tan() double tan(double x);Parameters of tan()The tan(x) function takes a single parameter x. x: is a double value representing the angle in radians for which the tangent value is to be computed.Return value of tan()The tan(x) function returns the tangent of the specified angle x which is passed in the form of radian. Example of tan() Function in CInput:double radian = π/4 // value of π = 3.141Output:The tangent of 0.785 radians (45 degrees) is 1.000The below program demonstrates how we can calculate the tangent for 30, 45, 60 and 90 degrees using the tan(x) function in C. C // C program to calculate the tangent of 30, 45, 60 and 90 // degree in C #include <math.h> #include <stdio.h> int main() { // 30 degrees in radians double a = M_PI / 6; // 45 degrees in radians double b = M_PI / 4; // 60 degrees in radians double c = M_PI / 3; // 90 degrees in radians double d = M_PI / 2; // Variable to store the results double res; res = tan(a); printf("The tangent of %.3lf radians (30 degrees) is " "%.3lf\n", a, res); res = tan(b); printf("The tangent of %.3lf radians (45 degrees) is " "%.3lf\n", b, res); res = tan(c); printf("The tangent of %.3lf radians (60 degrees) is " "%.3lf\n", c, res); res = tan(d); printf("The tangent of %.3lf radians (90 degrees) is " "%.3lf\n", d, res); return 0; } Output The tangent of 0.524 radians (30 degrees) is 0.577The tangent of 0.785 radians (45 degrees) is 1.000The tangent of 1.047 radians (60 degrees) is 1.732The tangent of 1.571 radians (90 degrees) is 16331239353195370.000Time Complexity: O(1)Auxiliary Space: O(1) Explanation: In the above program M_PI is a macro constant defined in the <math.h> header which represents the mathematical constant π (pi) which is approximately equal to 3.14159265358979323846 Comment More infoAdvertise with us Next Article C cos() Function P pankajbind Follow Improve Article Tags : C Programs C Language C-Functions Similar Reads time() function in C The time() function is defined in time.h (ctime in C++) header file. This function returns the time since 00:00:00 UTC, January 1, 1970 (Unix timestamp) in seconds. If second is not a null pointer, the returned value is also stored in the object pointed to by second.Syntax: time_t time( time_t *seco 1 min read C cos() Function cos() function in C programming is provided by the math.h header file and is used to calculate the cosine of an angle (x) where (x) is represented in radians. This function returns the cosine of a given angle value in radians for a right-angled triangle. Syntax of cos() double cos(double x);Paramete 2 min read sin() in C The sin() function in C is a standard library function to find the sine value of the radian angle. It is used to evaluate the trigonometric sine function of an angle. It takes the radian angle as input and returns the sin of that angle. It is defined inside <math.h> header file. Syntax of sin( 1 min read How to find arctangent with Examples What is arc tangent?The arctangent is the inverse of the tangent function. It returns the angle whose tangent is the given number. catan() is an inbuilt function in <complex.h> header file which returns the complex inverse tangent (or arc tangent) of any constant, which divides the imaginary a 15+ min read Tangent Function Tangent Function: Trigonometric function tan(x) is called a tangent function it is one of the main six trigonometric functions and is generally written as tan x. The tangent function is the ratio of the opposite side and the adjacent side of the angle in consideration in a right-angled triangle. In 7 min read hypot() Function in C The hypot() function in C is used to find the length of the hypotenuse of a right-angled triangle given the lengths of the other two sides. This function is particularly useful in various fields of science and engineering where distance calculations are required.The function is declared in the <m 2 min read Like