+ 1

How many return statements can be written in a function?

26th Jul 2016, 4:28 PM
supraja
supraja - avatar
4 Answers
+ 6
Multiple return statements can be written but the first one that is called will exit the function and return whatever you choose to return.
26th Jul 2016, 6:04 PM
Rob McBryde
Rob McBryde - avatar
+ 3
as many as return statements
27th Jul 2016, 4:32 PM
Jeevan Chaitanya
Jeevan Chaitanya - avatar
0
a lot
29th Jul 2016, 11:39 PM
Narek Tonoyan
Narek Tonoyan - avatar
0
see...when you write 'return' statement in any function whether it's a by-default or any defined function. when ..we reach the line where return statement will get execute it will get execute to return a value..this value can be used outside the function too.Note-the speciality of it is that when it gets executed it actually 'returns' leaving the further portion unexecuted..thus if you wrote a plenty of them..it will do 'return' after the first execution.
31st Jul 2016, 5:26 PM
sushant
sushant - avatar