+ 1

Are functions more efficient?

So my question is basically: Are functions more efficient? I mean, in the lessons and projects there were many exercises where we had to use functions but they could have been done without using them. Or are functions used mainly to make it easier to navigate through the code. Ex. Making calculations, then only just calling them.

2nd Sep 2021, 4:13 PM
Some1unknown
Some1unknown - avatar
3 ответов
+ 6
The main purpose of functions is reusability. For example if you have to do the same thing twenty times it is more efficient to write a function once and call it twenty times.
2nd Sep 2021, 4:15 PM
Simon Sauter
Simon Sauter - avatar
+ 3
For smaller program you might be wondering that why we are using functions whether we can do it without using functions But in large program when you need to excute a similar type of functionality for several times then function plays it's real role, cause writing similar types of program for a large number of times is never gonna efficient.
2nd Sep 2021, 5:11 PM
Saurabh
Saurabh - avatar
+ 2
Thank you!
2nd Sep 2021, 4:17 PM
Some1unknown
Some1unknown - avatar