Void Functions
A "void" return type means there is no information stored or returned after the function call. Here is the syntax template of a void function prototype:
void functionName(Parameter_DataType_List);
Here is the syntax template of a void function definition:
void functionName(ParameterList) { //Statement . . . }
A void function has a heading that names the function followed by a pair of parentheses. The function identifier/name is preceded by the word void. The parameter list with the corresponding data type is within the parentheses. The body of the function is between the pair of braces.
Example
In the above example, void printStars()
is
the function header. There is no parameter list, but the parentheses that
enclose the parameter list must be present. The braces enclose the body of
the function, the action part of the function. The output statement prints
10 stars. The return statement ends the function, but it is not required in
void functions.
In the main function, printStars()
is
invoked/called and used as a statement to print out the 10 stars.