+ 1

What is the purpose of using functions? Could anyone explain that?

1st Nov 2016, 6:32 AM
Samadov Abdullokh
Samadov  Abdullokh - avatar
4 odpowiedzi
+ 2
Not to repeat code. For ex. you wouldn't want to write 10 exactly the same lines of code more than once in your main code. That is where functions come in. Not only does it simplify to only 1 short line of code, it also allows you do to calculations and/or other complex things with variables with ease.
1st Nov 2016, 6:40 AM
nedas
nedas - avatar
+ 1
thanx so much
1st Nov 2016, 6:42 AM
Samadov Abdullokh
Samadov  Abdullokh - avatar
+ 1
One other benefit is that if you expect errors or other thinga in your code, you have to change it only once
2nd Nov 2016, 6:49 PM
Mathew
+ 1
if you have some operations "gathered" as functions, you can store definitions somewhere on the bottom of the code and use only their names. It os much easier to handle with coding espwcially if you want to change something later on. The program is easier to understand also for others. Moreover its essential for work in groups. One man writes "body", other one does functions needed. The only infomation needed to pass on is the parameters.
22nd Nov 2016, 6:31 PM
Marek Kaczycki
Marek Kaczycki - avatar