6.11.177 tanf Function
Calculates the trigonometric tangent function of a single precision floating-point value.
Include
<math.h>
Prototype
float tanf(float x);
Argument
x
- value for which to return the tangent
Return Value
Returns the tangent of x
specified in radians in the range
. NaN is returned if x
is
.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
float x, y;
errno = 0;
x = -1.0F;
y = tanf (x);
if (errno)
perror("Error");
printf("The tangent of %f is %f\n", x, y);
errno = 0;
x = 0.0F;
y = tanf (x);
if (errno)
perror("Error");
printf("The tangent of %f is %f\n", x, y);
}
Example Output
The tangent of -1.000000 is -1.557408
The tangent of 0.000000 is 0.000000