Example 1 — Common Radian Values
Use a portable π and print classic tangent results.
#include <math.h>
#include <stdio.h>
int main(void) {
const double PI = acos(-1.0);
printf("tan(0) = %.4f\n", tan(0.0));
printf("tan(PI/6) = %.4f\n", tan(PI / 6.0));
printf("tan(PI/4) = %.4f\n", tan(PI / 4.0));
return 0;
} How It Works
- Get π.
acos(-1.0)is a portable constant for π. - Pass radians.
PI/6is 30°;PI/4is 45°. - Known results.
tan(π/4) = 1;tan(π/6) ≈ 1/√3. - Link libm. On GCC, remember
-lm.

