+ 3

What does return mean exactly?

What does it mean to return a value? Please don't use return in your definition.

4th Dec 2017, 11:36 PM
Unidentified
Unidentified - avatar
2 Answers
+ 4
Hi man, Returns the value of the function - this means that the function can be used as a variable in an assignment statement or in another function (for example, printf). For example. There is a function do_something (); if it says for example return 2; then we can write A = 3 + do_something (); and it turns out that A = 5; More often the function does something and does not compute, for example rearranges the elements of the array. Then in return you can write for example error codes. 0 if all is well, 1 if not. In short, using the return operator, we assign some value to the function identifier, (that is, the function name), after which the function name can be used as an ordinary variable. Thus, the function is executed, does what it is supposed to do, and at the same time with the return function, a value is assigned to the function name. Sometimes it is useful. If you do not need to assign a value, then the values ​​for the error codes are used. Hope this help!
4th Dec 2017, 11:42 PM
stKhaDgar
stKhaDgar - avatar