This statement is used to terminate a loop abruptly. You have already seen the usage of this statement while discussing the switch-case construct. If the condition is true and the compiler finds a break statement, then the program will stop at that point. In listing 2.14, a loop is created to print numbers from 1 to 10. But since I have specified the break statement inside an if clause, the program will terminate after printing the numbers from 1 to 5.
In this part of the series, you have seen the working of different types of methods with the help of relevant source codes. The article also discussed the various programming constructs, including the different lopping statements such as for, while, do-while, and so forth. In the next article, you will learn about the different escape characters and other important topics, such as arrays.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |