C++ Flow Control

In this lesson, we will introduce Flow Controls in C++, their types, usage, and examples to better understand the topic.


C++ Flow Control Explained

“Control statements are statements used in programming languages to handle the program’s execution.”

In C++, statements are typically executed in the order that they occur, sequentially from top to bottom. Your program statements might not always be performed sequentially, one after the other. You may need to execute or skip a specific set of instructions based on a condition, jump to another set of statements, or repeatedly execute a group of statements.

According to the application logic, control flow statements in C++ are used to change, reroute, or control program execution flow.

We will learn about the control flow types in this lesson and how to use them with examples.


Control Statement

Decision-Making Statement

  • C++ if Statements
  • C++ if else Statements
  • C++ if else if Statements
  • C++ Switch Case Statement

Looping Statement

  • C++ For Loop
  • C++ While Loop
  • C++ Do-while Loop

Jump Statement

  • C++ break Statement
  • C++ continue Statement
  • C++ goto Statement

Decision-Making Statement

There are cases where we want a block of code to run only when a specific condition is met. With various decision-making statements in C++, a computer can choose which block of code to run based on many conditional options. Selection statements are another name for decision-making statements. A decision-making statement assesses one or more condition expressions to determine if the result is TRUE or FALSE.

The condition result helps determine which block of statements should be executed if the condition is TRUE or FALSE respectively.

This concludes the C++ Flow Control lesson. In the next lesson, you will learn about if Statements in C++.