what is the function of return | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the function of return

When I entered 200 in place of 0 it did nothing so what's it's function

10th Jul 2016, 6:48 AM
Abhay Sharma
Abhay Sharma - avatar
1 Answer
0
return will set the value of the return to the variable that called it. for example, let's say we have this: int i = setITo15 (); then in an integer function setITo15 we have this declaration: into setITo15 () {return 15;} when this function finishes the varable that called it, i, will be set to 15. if you're referring to return 0 I'm int main it simply returns 0 once the program reaches the end of its code, essentially saying that I did everything I was told to do. of the program stopped prematurely it would return a different code like -156725 or something like that. in this case it's just a difference between executing the program completely or not
10th Jul 2016, 7:19 AM
destro