As you learn programming you will find that repetitive code is both annoying and unsightly. Although in terms of writing the code, a simple copy-paste action will satisfy the requirement, it is still a bad way to do things. It can cause your code to become long and the chances of making a mistake in copying & pasting code are also there.
To avoid these problems and also to compartmentalize your code, you can use certain constructs found in modern programming languages called Procedures and Functions. The usage of these constructs enables you to write code which is structured and therefore easier to debug. The biggest advantage of using Procedures and Functions is that they are not executed unless they are called for. For example, you can have a million Procedures and Functions in your source code, but if none of them are called for in the main part of your code they are non-existent in your final compiled program.
You can visualize Procedures as a mini-program within your program. This means that you can define variables, arrays, etc within it as well as call other procedures or functions. One of the most useful features of Procedures is that any variables defined within that Procedure (aka Local Variables) only exist within the scope of that Procedure. The moment the procedure completes execution, those variables disappear.
Functions are similar to Procedures except that they are expected to return a value. In order to do this the Function is given certain values to work with which it then manipulates to return a value. For example, a Function that calculates a circles radius will require the value of the radius to be added to it.
