Functions are probably the most powerful construct in programming. They allows you to pull out shared code and reuse it anytime to reduce typing, reduce bugs and make your code more readable. 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.

A function has a return type, a name, parameters and the body. If the function doesn't return anything, you just write void 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.

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.