/* Cosine.c: cosine function approximation */ /* */ /* author: Rainer Doemer */ /* */ /* modifications: */ /* 10/02/05 RD initial version */ #include /* main function */ int main(void) { /* variable definitions */ double x, y; /* input section */ printf("Please enter real value x: "); scanf("%lf", &x); /* computation section */ y = 1 - (x*x)/(2.0*1.0) + (x*x*x*x)/(4.0*3.0*2.0*1.0) - (x*x*x*x*x*x)/(6.0*5.0*4.0*3.0*2.0*1.0); /* output section */ printf("cos(%f) is approximately %f\n", x, y); /* exit */ return 0; } /* end of main */ /* EOF */