Return Function

+1 Pavle Knezevic · November 14, 2014
I dont understand return function so much.Can anybody write me down on how to use return function and some examples.It would be big help.

Post a Reply

Replies

Oldest  Newest  Rating
+2 Ibrahim Tuzlak · November 15, 2014
Do you mean something like:
return 0;

?

return is a [value] a single function returns after done executing. It could be an error code, or a custom calculation.
For example:
int calculate(int a, int b)
{
return a + b;
}

int c = calculate(5,5);

In the above example, the new value of c is whatever calculate() returns (which is 10, in this case).

Now, return 0 is somewhat universal return value that says "This function has done executing, everything went well".

Hope I helped,
Cheers!
0 Bernard Pyc0d333 Parah · December 9, 2014
The most important thing about programming is understanding the concepts.I suggest that you continue with the ones you are learning now. C++ is not a bad first language because it combines many different programming techniques which will help you so much when you are learning another language.
0 c student · December 9, 2014
more specifically, the return value is used to return some value from a function.  when the program enters a function (could be main or a sub-function of main), values are completely independent when declared within it, meaning they do not correspond with any of ones from any other function (not even the ones passed into them as arguments as they are just copied into their own memory stack, unless they are passed in by reference).  because of this, the return function is used to pass back a value to wherever it was called and then everything that was created/stored within that function stack would be destroyed.

in my opinion, it's not the matter of which programming language you use but rather how the language works and how it interacts with the computer's memory.  if you can understand these levels of computation, you'll be much better off.  in my case, i started with c and since c has a lot to do with low-level memory manipulation, it gives me a better understanding of what happens deep down inside.

hope you understood and good luck with programming! 8-)
0 Pavle Knezevic · November 16, 2014
Tnx everybody this was mind blowing for me.Now I understand about return.Tnx so much guys.And I have one more question:

Should i be studying C++ as my first programming language or start studying some other programming langunage.

Im currently on 21 tutorial about XHTML and CSS so any suggestions.

Hvala majstore super si.Velika pomoc.
0 Pavle Knezevic · November 16, 2014
I started Python already .When i learn XHTML and CSS from BuckysRoom then im gonna start studying javaScript
-1 Pavle Knezevic · November 17, 2014
WOW tnx dude
  • 1

C++

107,024 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator