Library Function Math h Tan()

Tan() library function in Math

The tan() function is a part of the C math library and is used to calculate the tangent of a given angle. The angle is specified in radians. The tan() function takes a single argument, which is the angle in radians for which the tangent is to be calculated. The tangent of an angle is the ratio of the length of the side opposite the angle to the length of the side adjacent to the angle in a right triangle. Let us understand more about Library Function Math h Tan().

Library Function Math h Tan()

Library Function Math h Tan()

The tan() function takes a single argument of type double, float, or long double and returns the tangent of the angle as a value of the same type. Here is the syntax for the tan() function in C:

#include double tan(double x);
float tanf(float x);
long double tanl(long double x);

Here is an example of how to use the tan() function in C:

Run
#include<stdio.h> 
#include<math.h>
int main()
{
double angle = 1.57;
double tangent = tan(angle);
printf("The tangent of %f is %f\n", angle, tangent);
return 0;
}

Output

The tangent of 1.570000 is 1255.765592

Keep in mind that the tan() function works with angles specified in radians, not degrees.  To convert an angle from degrees to radians, you can use the following formula:

radians = degrees * (M_PI / 180)

Where M_PI is a predefined constant in the math.h library that represents the value of pi.

Some facts about Ctan() function

  • The tan() function is a mathematical function that calculates the tangent of an angle.
  • The tan() function is defined in the C math library, which is typically included in C programs using the #include directive.
  • The tan() function takes a single argument, which is the angle in radians for which the tangent is to be calculated.
  • The tan() function returns a value of type double, float, or long double, depending on the type of the argument.
  • The tan() function is an element of the trigonometric functions, which also include sin(), cos(), cot(), sec(), and csc().
  • The tangent of an angle is the ratio of the length of the side opposite the angle to the length of the side adjacent to the angle in a right triangle.
  • The tan() function is closely related to the sin() and cos() functions, as the tangent of an angle is equal to the sine of the angle divided by the cosine of the angle.
 

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription