BEGINNER: declare function after loop?

I'm used to having to write a function before i call it.
In an example i'm trying out now I see in the loop a function is called, but only after/ below the loop this function is made.

So the order of calling/ making functions doesn't matter?
Variables are defined at the beginning of the script, why not functions? If only for readability?

Peter

The arduino IDE puts the function definitions in automatically for you just before it compiles. But you can do it yourself if you want.

I'm used to having to write a function before i call it.

The compiler needs to see the function, or a prototype for the function, before you can call it. As Grumpy_Mike points out, the IDE will usually create the function prototypes for you, so you can define the functions anywhere.

There are exceptions, like when using reference arguments. In those cases, you need to define the function, or function prototype, before you first call it.

thanks!

IMHO it's good practice to write function prototypes yourself rather than rely on the IDE to do it for you. While you can get away with it with arduino programming other C/C++ environments are not so forgiving.