Summary
We have encountered various repetitious looping techniques, from the ridiculous (brute-force iteration) to the sublime (various loop statements with break
, continue
, and goto
). You can use loops for a wide variety of purposes: to evaluate all the elements of an array, to traverse lists, trees, and other data structures, to get multiple inputs from the user, and so on. We will encounter these different uses of loops in later chapters. We have explored the use of goto
in a variety of ways; in reality, goto
should be used sparingly and with great restraint.
With functions, conditional expressions, and – now – looping statements, we conclude our journey through C flow-of-control statements. Nearly all of these concepts can be easily translated into other programming languages.
In the bulk of the remainder of the book, we'll broaden our understanding and ability to manipulate data well beyond the simple forms we have so far encountered. In the next chapter...