Klim Sanych, good evening. I don’t even know what confuses me more, it’s my illiteracy or the question of having the “smallest” on Habré.
So, if there are such, then now we will analyze what a function is, its parameters and arguments using the simplest examples from real life. Go
Let’s imagine that you need to read someone’s plan for the day. You open it in and see the following:
It seems, nothing unusual at first glance. But if you try to follow this plan, you may encounter one problem: it is not clear what exercises to do under the “Charging” item. Of course, you can come up with your own list of conditional squats and push-ups, but this will be your plan when the task is completed.
Let’s look a little lower, maybe we’ll find a clue:
As we can see, quite unexpectedly appeared, let’s call, “function” in the plan called “Charging”, which already describes the list of exercises of this plan for the day. Can we start? It’s not so simple. We don’t know how many times you need to perform certain actions in the “Charging” section. Let’s be careful again look at this section:
It is not clear how we could not notice all the letters next to the exercises and in brackets, Let’s call them a word “parameters“. Now it is clear to us how many repetitions we need to perform for each exercise, we begin:
Wake up -> Start Exercising -> Squat X times -> Push-ups… so stop, what the hell X times, we need to take another look at the to-do list:
Apparently, then it will be necessary to go to the ophthalmologist. Great, now you can use the passed functions “arguments“and finally execute the plan..
And now let’s open the conditional Visual Studio and see the code:
Oops, wrong screen:
I don’t think much explanation is needed here. Well, except about prefix and postfix increment(decrement). This is if (++i and i++), but it’s already