C++ Return Statement Explained

The original purpose of a return statement was to initiate a predefined response to a particular function. It is similar to that of a “COUT” statement; the only difference for return statements is that it saves the final results of the formula in its memory for easier access to be called at a later time. It is always a good habit to close off whatever formula that you are working on. Because when you write a return statement within a function, it also acts as a conclusion to the entire function, thereby enhancing readability. Likewise, it is also a very good way to avoid syntactical and logical calculation errors. There are also other circumstances in which we do not need the function to return the results, in that case, we would use the “VOID” function to specifically ask the compiler to return nothing.

Leave a comment