d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Not Sure I Understand Return Statements
Prev12
Add Reply New Topic New Poll
Member
Posts: 3,028
Joined: Mar 23 2016
Gold: 7,568.50
Apr 28 2016 05:13am
Unrelated but I think you would benefit from looking up the terminology and differences between subroutines, procedures, functions, methods, etc. :)
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Apr 28 2016 08:09am
I suggest learning by doing. We can only explain the same thing so many ways.

Create a for loop thay iterates 0-20 and a single if condition. If I ==10 then break. Outside of the if statement print a line of text.

Compile and run it, you will see break exits the scope of the for loop and prints the statement. Changing break to return you will notice it will not print the statement since it returns immedietly.

I explained this and why it happens on the first page that cater linked.

Code
Void test(){
for(i=0;i<20;i++){
If(I==10){
Break;
}
}
Printf("wow\n");
}


This post was edited by AbDuCt on Apr 28 2016 08:11am
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll