hi guys, i wonder if there is technically any difference between using break or return in order to quit a loop without reaching its condition?
serkan sendur 821 Postaholic Banned
Recommended Answers
Jump to PostYou're talking about c++?
The answer is yes:
break will only break out of the 'most nested loop' . For example:int main() { for (int i = 0; i < 10; i++){ for (int j = 0; j < 10; j++){ if (j == 5) break; …
Jump to Post
break;
Just jumps, after an evalution.return(x);
Will probably store the value were ever it feels appropriate, then tells the OS to return back to the called procedure.
Jump to Post> then tells the OS to return back to the called procedure.
The OS isn't involved in such things.
All 10 Replies
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
MosaicFuneral 812 Nearly a Posting Virtuoso
Salem 5,138 Posting Sage
serkan sendur 821 Postaholic Banned
Nick Evan 4,005 Industrious Poster Team Colleague Featured Poster
serkan sendur 821 Postaholic Banned
kbshibukumar 1 Junior Poster in Training
Narue 5,707 Bad Cop Team Colleague
kbshibukumar 1 Junior Poster in Training
Narue 5,707 Bad Cop Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.