Page t007, go to NEXT,
PREVIOUS, INDEX
Standard Libraries
There are no intrinsic functions in C
There are standard libraries
One must include header file to make library functions available
Example
/* Read an angle in degrees and print its cosine. */
#include <stdio.h>
#include <math.h>
int main()
{
float angle;
scanf ("%f", &angle);
printf ("Cosine = %f\n", cos (angle/180.0 * 3.14));
return (0);
}
- functions can be input to printf
- do "man math" to get a list of functions
- useful constants are defined as well
- C shares same library
C Course, 15-jan-1997,
Peter Klok,
pfk@hef.kun.nl