1 / 6

Using Library Functions

C. Using Library Functions. Basics. You must include the header file in your program # include < > Then use the needed function by calling it You must know the parameters and the return type. Most used headers. stdio.h string.h stdlib.h math.h graphics.h ….

jerry-henry
Télécharger la présentation

Using Library Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C Using Library Functions

  2. Basics • You must include the header file in your program • # include < > • Then use the needed function by calling it • You must know the parameters and the return type

  3. Most used headers • stdio.h • string.h • stdlib.h • math.h • graphics.h • …

  4. Functions in math.h • sin • cos • tan • acos • asin • atan • log • pow • …

  5. Parameter and return type • double sin (double x) • Means the parameter is double • Return type is also double • So you should write- double result, angle; angle = 45.0 * 3.14159 / 180.0; result = sin(angle);

  6. Parameter and return type • double sin (double x) • If you use int, it will not generate any error • But you may lose data • Get wrong results int result, angle; angle = 45.0 * 3.14159 / 180.0; // angle = 0 result = sin(angle); // result = 0

More Related