The branching control structures allow the flow of execution to jump to a different part of the program. The common branching control structures that are used with other control structures are: break, continue and goto. These are rarely used in modular structured programming with one exception. That exception is in relation to creating the case within the selection category of control structures. Within C++ the break is used with the switch to create a structure that acts like the traditional case structure. There is one other branching control structure that is often not viewed as branching control structure. It is: return; which is used with functions. Thus, there are two commonly used branching control reserved words used in C++; break and return. Additionally, we will add to our list of branching items a pre-defined function commonly used in the C++ programming language of: exit; that is part of the C standard library (cstdlib). Some definitions:
Definitions
- Definition 1: branching control structures
- Allow the flow of execution to jump to a different part of the program.
- Definition 2: break
- A branching control structure that terminates the existing structure.
- Definition 3: continue
- A branching control structure that causes a loop to stop its current iteration and begin the next one.
- Definition 4: goto
- A branching control structure that causes the logic to jump to a different place in the program.
- Definition 5: return
- A branching control structure that causes a function to jump back to the function that called it.
- Definition 6: exit
- A pre-defined function used to prematurely stop a program and jump to the operating system.
We will discuss each item indicating which ones are allowed or not allowed within good structured programming practices.







Structured Programming

"Used in the Computer Programming Fundamentals I course."