Why Should a Function Return a Value?

TIME : 2016-01-07
Why Should a Function Return a Value?

Not every function needs to return a value. A function declared as void, for instance, is designed specifically not to return anything.

Functions should return values when their result is used as part of an expression, that is, when they serve as a right-hand-side value (an rvalue). In those cases, the returned value is essential for the expression to work. Otherwise, a void function is perfectly fine.