+ 1

What actually return do?

2nd Jan 2017, 1:10 PM
Wahid S
Wahid S - avatar
4 Respuestas
+ 6
C++ wise, 'return' keyword is used to transfer a specific value out from a function back to wherever the function is called. E.g. string star_wars () { return "jedi"; } int main() { cout << star_wars(); return 0; } // outputs "jedi"
2nd Jan 2017, 1:22 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
In computer programming, a return statement causes execution to leave the current subroutine and resume at the point in the code immediately after where the subroutine was called, known as its return address. The return address is saved, usually on the process's call stack, as part of the operation of making the subroutine call. Return statements in many languages allow a function to specify a return value to be passed back to the codethat called the function. Source: Wikipedia. (checked and it is explained just fine)
2nd Jan 2017, 1:20 PM
Iván
Iván - avatar
+ 3
there are many uses of return the most common use is it is the output of the function. the function acts like the value it returns var a=6. a is 6 var b=a. b is 6 var c=increase(a) c is 7 if function increase(a){ return a++; }
2nd Jan 2017, 1:47 PM
Sandeep Chatterjee
0
It save any value assigned to the function name. For example. Int func() { Int x =4, y=2, z=0; z=x-y; return z; } So now the value of z which is 2 is place in func(). Whenever you call this function in main, and print it out will produce 2. cout<<func() ;
2nd Jan 2017, 1:15 PM
shaufyq sone
shaufyq sone - avatar