Math Functions (Using COSINE Function)
Write a program to show the use of Math Functions. Hints: We often use standard mathematical functions such as cos,sin,exp,etc. We shall see now the use of a mathematical function in a program. The standard mathematical functions are defined and kept as a part of C math library. #include<math.h> #define PI 3.1416 #define MAX 180 main() { int angle; float x,y; angle = 0; printf(" Angle Cos(angle)\n\n"); while (angle <= MAX) { x = (PI / MAX) * angle; y = cos(x); printf("%15d %13.4f\n", angle,y); angle = angle + 10; } } Output: Angle Cos(angle) 0 1.0000 10 0.9848 20 0.9397 -- ---- -- ---- 180 -1.0000