Chapter 8. Functions

Table of Contents

Defining Functions
Function Calls
Library Functions

Defining Functions

A function definition can appear anywhere in the program source at global scope. Function names share the syntax as variable names; they must begin with a letter or underscore and thereafter can contain any combination of letters, digits and underscores. See also the section called “Visibility of Built-in Symbols”.

A function definition consists of the function's return type (or the special keyword void if it does not return a value) followed by the function name, followed by the function arguments in parenthesis.

Example 8.1. Function Declaration Syntax

void func1()
{
    // Statements
}

int func2()
{
    // Statements

    return 42;
}

int add(int a, int b)
{
    return a + b;
}

int global_var;
void increment()
{
    global_var++;
}