cc++ control structures

Control Structures in C++

Control structures are required for sequence control in programs and are an important part of structured and imperative programming. The flow control is based on loops and branches, which are mostly linked with logical expressions of Boolean algebra. This means that instructions in a program are only partially executed.

There are three main types of control structures in C++ programming:


In a sequential structure, instructions are executed one after another in the order in which they appear.


In a selection structure, the instructions are executed based on a condition. There are two types of selection structures:
– if statement: the if structure allows you to execute a block of code if a condition is true.
– switch-case statement: The switch-case structure allows you to select one of several code blocks to execute based on a value.


In an iteration structure, a block of code is executed repeatedly until a certain condition is met. There are two types of iteration structures:
– for-loop: the for loop allows you to execute a block of code a specified number of times.
– while-loop: With the while loop, you can execute a code block until a certain condition is met.