Skip to main content

Posts

Showing posts with the label math.h

Math library

This post lists the important functions available in the “math.h” library of C with their examples. Before continuing, you must know that we need to include the “math.h” library while compiling our program by using -lm ($cc -c filename.c  $cc -o filename filename.c -lm). Function     Description                                 Example sqrt(x)       square root of x                              sqrt(4.0) is 2.0                                                                          sqrt(10.0) is 3.162278 exp(x)        exponential (ex)                            exp(1.0) is 2.718282                                                                          exp(4.0) is 54.598150 log(x)        natural logarithm of x (base e)       log(2.0) is 0.693147                                                                          log(4.0) is 1.386294 log10(x)     logarithm of x (base 10)                log10(10.0) is 1.0