A function definition has the following form:
<RETURNTYPE> <FUNCTIONNAME> ( <ARGUMENTLIST?> )
{
<FUNCTIONBODY>
} |
Examples of legal function definitions are:
float giveme_pi () { return 3.14f; } // returns pi (very inaccurately)
int add_numbers (int a, int b, int c) // function that adds 3 numbers
{ // and returns the result
return a + b + c;
}
void noarguments_voidreturn () // a void function with no arguments
{
dosomething();
} |
Recursive function invocation is supported by butter. That means the the classic recursive fibonacci program will work as usual.
/* recursive fibonacci function, only good for benchmarks */
int fibo (int a)
{
if (a <= 1) return 1;
return fibo (a - 2) + fibo(a - 1);
} |