0
User defined functions
Is it better to use user defined functions in C++ more often than writing programs without them...if so, what are its benefits?
3 Answers
+ 3
Functions make your code shorter. It can devide your code into some different part, make your code clear. If there are some problems, you can only modify your function, dont need to change the structure of your codeđ
+ 2
Just extending into these answers with an example. Imagine writing that 50 lines of code every time you need to calculate that particular thing instead of defining it as a function and just calling it with a f().
+ 1
1.) You can reuse the function, whenever you need it again in your program;
2.) in allows you to structure your code, like chapters in a book, one for each topic, making it easier to read;
3.) each function has it's own names (variables and functions), so you can use whichever name you like and don't have to fear it messes with your other code somewhere.