Namespaces
Variants
Views
Actions

Flow control

From cppreference.com


All programming languages provides some way to control the order the program is executed. Usually the following flow control primitives are provided:

  • Conditional statements: a set of statements is executed only if a condition is met
  • Loops: a set of statements is executed zero or more times
  • Jumps: the program is continued at a different statement
  • Functions: a set of statements adapted for reusability

In this section we will discuss the first three. Functions are discussed in functions.

The C++ language provides the following control flow statements:

  • Conditional statements: if and switch statements.
  • Loops: for, while and do-while loops.
  • Jumps: break, continue and goto statement.