Functions

Also known as sub-routines!

 

All programs must at least have the main( ) function.

 

A function takes the form of:

 

return_data_type function_name ( argument, list)

{

body of the function ;

}

 

The return_data_type is the data type of the value to be returned by the function.

 

The function_name is your preferred name for the function. The function signature, consists of the function name and argument list.

 

The argument list is a list of none or more parameters / arguments that are passed to the function, specifying its data type and name to be used within the function.

 

The function body consists of one or more statements within the function's { statement block } that define what the function does.

 

To invoke a function, provide the name of the function along with any arguments within its parentheses.

Leave a Reply