0
Why we define functions?
4 Answers
+ 5
Your example definitely does not demonstrate the necessity of using functions, but imagine if you have 50 lines of code worth of calculations, which you have to use multiple times over the span of your entire program, it will be a better idea to write those 50 lines as a function and call the function every time you need to use it, instead of duplicating those 50 lines for each calculation.
+ 3
Reuseability. That way you'd only have to call the function instead of writing that code block over and over again.
0
Jomari Pantorilla Hatsy Rei
Thanks for answering but I'm still unable to understand it. Can you provide me a real life example to show the difference?