4.8. Functions

A function is a self-contained section of code written to perform a well-defined action. Functions are usually created when it is required to perform an operation at several different parts of a main program. In addition, it is a good programming practice to divide a large program into a number of smaller independent functions. The statements within a function may be executed by calling (or invoking) the function.

The syntax of a general function definition is as shown in Figure 4.25. The data type indicates the type of data returned by the function. This is followed by the name of the function, and then a set of brackets are used where any comma separated arguments can be declared inside the brackets. Then the body of the function ...

Get SD Card Projects Using the PIC Microcontroller now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.