A function is a subprogram that can act on data and return a value. Some functions may accept certain input parameters (such as printf), some may return a value of a certain data type (such as kbhit) and some may accept as well as return a value (sqrt).
Every C program has at least one function, the main( ). When a program is executed the main( ) is called automatically. The main( ) may call other functions and some of them might call other functions.
Each function has a unique name and when the name is encountered while in execution the control of the program is transferred to the statement(s) within the function. When the function is ended (returns) the control is resumed to the next statement following the function call. Well designed functions perform a specific and easily understood task. Complicated tasks should be broken down into multiple functions and then each can be called in the proper order.
No comments:
Post a Comment