Programming Functions and why are they so special

819 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

Technically, all programming functions has outputs, but in some cases we don’t see them:

1. The function requires multiple outputs but the programming language does not support functions with multiple outputs. In this case we get around the problem by using pointer inputs to get their physical addresses.
2. It create an output(s) that is either physical or an essential component in your framework or library. They are either fixed or declared so you can’t define them.
3. Also in object oriented programming you can call “methods” of an object to change its properties. Since properties of the class of the object can be directly accessed by the method there’s no need of returning an output. This is really meaningful because it allow encapsulation.

Anonymous 0 Comments

The ones that don’t return anything are for being read by a person. Not read into. They are supposed to allow you to think instead of doing the math and then you can continue if you are doing it. A computer will only send to the screen in those events, and the rest of it is doing nothing by then. In otherwise, the computer may hold a chip that will expect to be receiving input and that will endanger the process become a “single” operation and not just a “dedicated” one.