Function Body

A “function body” is a compound statement containing the statements that specify what the function does. The syntax is:

Syntax

function-definition :
declaration-specifiers opt declarator declaration-list opt compound-statement

compound-statement : /* The function body */
{ declaration-list opt statement-list opt }

Variables declared in a function body, “local variables,” have auto storage class unless otherwise specified. When the function is called, storage is created for the local variables and local initializations are performed. Execution control passes to the first statement in compound-statement and continues until a return statement is executed or the end of the function body is encountered. Control then returns to the point at which the function was called.

A return statement containing an expression must be executed if the function is to return a value. The return value of a function is undefined if no return statement is executed or if the return statement does not include an expression.