Programming Functions and why are they so special

798 views

I’m still trying to wrap my ahead around this concept.

I’ve done basic maths, so I know that f(x) = x is like a function, but I can’t find an intuitive way of explaining why some functions don’t have to return values. In addition, what separates functions from just lines of code?

In: Technology

12 Answers

Anonymous 0 Comments

You use functions to break up the code into pieces. Each function should perform one task, if it’s more than that, it can be broken up into even more functions (that’s sort of what abstraction is).

Some functions may need to return a value, but some may not at all. If you have a function that just deletes a file, you don’t need to return anything from it. But if you have a function that adds two numbers, you need to return the result.

You are viewing 1 out of 12 answers, click here to view all answers.