/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ /* chap_7_math_example.c */ /* This example uses two functions --- mytan and main --- */ /* to calculate the tangent value of a number, and to check */ /* the calculation using the sin and cos functions. */ #include #include /* This function calculates the tangent using the sin and */ /* cos functions. */ double mytan(x) double x; { double y, y1, y2; y1 = sin(x); y2 = cos(x); if (y2 == 0) y = 0; else y = y1 / y2; return y; } main() { double x; /* Print values: compare */ for (x = 0.0; x < 1.5; x += 0.1) printf("tan of %4.1f = %6.2f\t%6.2f\n", x, mytan(x), tan(x)); }