tan function
Related library: math.hThe tan function returns the tangent of number in radians.
Usage
| double tan(double number) |
Input Parameters
Where
number is the number that will be calculated.
Return Value
If number is NAN or INFINITY, tan will return NAN.
Note: For areas where the tangent should produce an error because of an asymptote, the tan function is not accurate and instead returns a large number. The variable errno does not change.
Example
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
int main()
{ double input; double output;
printf("Please enter a double: "); scanf("%lf", &input);
output = tan(input); printf("The tangent of %f is %f in radians\n", input, output);
output = tan(input * PI / 180); printf("The tangent of %f is %f in degrees\n", input, output);
return 0;
}
|
History
We have no records of the history of this function. Know a source? Contact us.
Notes and Warnings
Understanding the Code
- Ask user for a number.
- Find the tangent of the number, and output the results.
- Find the tangent of the number again, but converted to degrees, and output the results.
Example Runs
Please enter a double: 5
The tangent of 5.000000 is -3.380515 in radians
The tangent of 5.000000 is 0.087489 in degrees
Please enter a double: 180
The tangent of 180.000000 is 1.338690 in radians
The tangent of 180.000000 is -0.000000 in degrees
Please enter a double: 270
The tangent of 270.000000 is -0.178839 in radians
The tangent of 270.000000 is 216235426413811.593750 in degrees
Please enter a double: 1.5707963267948966192313216916398
The tangent of 1.570796 is 16331239353195370.000000 in radians
The tangent of 1.570796 is 0.027422 in degrees
Please enter a double: 0
The tangent of 0.000000 is 0.000000 in radians
The tangent of 0.000000 is 0.000000 in degrees
|

Er zijn nog geen reacties geplaatst!
Je bent niet ingelogd! Meld je
hier aan of log je aan de rechterkant in!