> I guess understanding goto statement, is difficult than understanding looping construct for beginners , right ?
The goto statement, in isolation, is not difficult to understand for anyone.
The internet is rife with
goto horror stories, but in reality, it is a very simple construct that does not do any of those terrible things it is routinely accused of doing.
http://www.cplusplus.com/forum/lounge/122363/#msg666967
The looping constructs in the language (
while,
do-while,
classical-for and
range-based-for) are ready-made canned constructs for the four canonical loop forms most commonly encountered in programming.
Using these ready-made constructs are easier for all of us (particularly so for beginners) when the loop that we want to write falls under one of these canonical looping forms. These are the kinds of loops we would need to write almost all of the time, and these prefabricated canonical constructs make the code less error-prone and more readable.
Consider writing a loop using
goto (working out the loop logic from first principles) only when a non-canonical loop-form is actually required. That is, only when, some one, who believes in
evil in certain programming constructs, would strongly recommend a
'bool-controlled-while-loop' with a few
continues and/or some number of
breaks thrown in for good measure.