+ 1

How will I know when to use a function and what to write in a function?

help.. it is part in my exam and actually I'm kind of confused 😢

13th Nov 2016, 11:23 PM
Bijoy
3 Antworten
+ 2
Functions allow you to write "modules" for your program. You can write a function to do pretty much anything you want: Print something, calculate an operation and return its value, etc. Then call the functions from anywhere in your program once you require them. This makes your code much more easier to read and avoids code repetitiveness.
14th Nov 2016, 12:14 AM
ABC
ABC - avatar
+ 1
You will use the function when you know that you will do something several time in your program. So you use function for avoid to repeat same thing several time.🙂
13th Nov 2016, 11:49 PM
Joel Azongnissou
Joel Azongnissou - avatar
0
in addition to the answers before: when your function is defined at beginning of the program it's easier for make changes. You also can put the code into an include file for the use in other programming.
16th Nov 2016, 9:20 AM
Andreas Kretzschmar
Andreas Kretzschmar - avatar