icp/oer/courses/c-basics/sections/03-functions/07-funktions/content.html

22 lines
1.4 KiB
HTML

<p>
Functions are probably the most powerful construct in programming. They allows you to pull out shared code and <b>reuse</b>
it anytime to <b>reduce typing</b>, <b>reduce bugs</b> and make your code more <b>readable</b>.
It also allows to break down your program in more understandable chunks of code, which you can name.
This highly increases the readability and maintainability of your program.
Last but not least it allows you to use recursion. But more on that later.
</p>
<p>
A function has a <b>return type</b>, a <b>name</b>, <b>parameters</b> and the <b>body</b>.
If the function doesn't return anything, you just write <b>void</b> as the return type.
The name is used to call the function and the parameters define, what arguments you have
to pass to the function and which types they need to be.
The body finally holds the code, which gets executed, when the function gets called.
</p>
<p>
You will probably hear diffident names for what we are calling functions.
The most accurate are procedures ore subroutines. These mean exactly what we described before.
Sometimes you will hear the term method. This is a term from object oriented programming and describes a procedure, which is a member of an object.
The term functions is a little bit overloaded. Normally when it is used,
people talk about procedures but it is also used in the functional programming paradigm.
</p>