Functions Methods for the smallest

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:

super plan
super plan

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:

super plan with "function"
super plan with “function”

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:

super plan with function c "parameters"
super plan with function with “parameters”

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:

super plan with functions, parameters and passed functions "arguments"
super plan with functions, parameters and “arguments” passed to functions

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..

do the exercises.  charging is important!
do the exercises. charging is important!

And now let’s open the conditional Visual Studio and see the code:


Oops, wrong screen:

Wow, was it that easy?
Wow, was it that easy?

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

ok, I'll tell you in the next post.
ok, I’ll tell you in the next post.

Similar Posts

Leave a Reply