Use of Math function


Sample program : use of math function
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. If we want to use any of these mathematical functions, we must add an #include instruction in the program. Like #define, it is also a compiler directive that instructs the compiler to link the specified mathematical functions from the library. The instruction is of the form
                #include < math.h >
math.h is the filename containing the required function. The program illustrates the use of cosine function. The program calculates cosine values for angles 0, 10, 20,….., 180 and prints out the results with headings.


Output :





Another #include instruction that is often required is
                #include < stdio.h >
Stdio.h refers to the standard I/O header file containing standard input and output functions

Comments

Popular posts from this blog

Addition 2 number in C Language

Input and Output in C

Comments in C