TAN Function in C

The C tan Function is a C Math Library Function. It is helpful to calculate the Trigonometry Tangent value for the specified expression. The syntax of the tan in C Programming is

double tan(double number);

Let us see the mathematical formula behind this Trigonometry Tangent function:

Tan(x) = Length of the Opposite Side / Length of the Adjacent Side

TAN Function in C Example

The tan function in the C math library allows you to calculate the trigonometric Tangent for the specified values.

This program asks the user to enter his/her own value. Then it will find the tangent value of the user-specified value. Please refer to the C ATAN Function article to calculate the Arc Tangent of the specified expression.

/* Example for TAN Function in C Programming */

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

int main()
{
  double tanValue, number;
  printf(" Please Enter the Value to Calculate Tangent :  ");
  scanf("%lf", &number);
  
  tanValue = tan(number);
  
  printf("\n The Tangent, or Tan value of %lf = %f ", number, tanValue);
  
  return 0;
}
TAN Function in C programming 1

C TANGENT Function Example 2

This C Programming example allows the user to enter the value in degrees. Next, we are converting the degrees to Radians. And finally, we are finding the Tangent value of the radian

/* Example for TAN Function in C Programming */

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

#define PI 3.1415926
int main()
{
  double tanValue, radianVal, degreeVal;
  printf(" Please Enter an Angle in degrees :  ");
  scanf("%lf", &degreeVal);
  
  // Convert Degree Value to Radian  
  radianVal = degreeVal * (PI/180);
  tanValue = tan(radianVal);
  
  printf("\n The Tangent, or Tan value of %f = %f ", degreeVal, tanValue);
  
  return 0;
}
 Please Enter an Angle in degrees :  60

 The Tangent, or Tan value of 60.000000 = 1.732051