C tan function gets the tangent of arg

Syntax

C tan function has the following format.

  • float tanf(float arg);
  • double tan(double arg);
  • long double tanl(long double arg);

C tan functions are from header file math.h.

Description

C tan functions return the tangent of arg.

Parameter value of arg must be in radians.

Example

The following code shows how to use C tan function to calculate the tangent of arg.


#include <math.h>
#include <stdio.h>
/* ww w .j av  a2  s .c  o m*/
int main(void)
{
  double val = -1.0;

  do {
    printf("Tangent of %f is %f.\n", val, tan(val));
    val += 0.1;
  } while(val<=1.0);

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h