Answer
In a program, a control structure determines the order in which statements are executed. The following are the basic control structures in the programming languages:
Sequential
In Sequential execution each statement in the source code will be executed one by one in a sequential order. This is the default mode of execution.
Selection
The selection control structure is used for making decisions and branching statements; the following are the basic selection statements in the programming language.
if:
The If statement checks for the condition and if the condition is satisfied it executes the statements in the “if” block, otherwise it exits the “if” block.
Syntax:
\begin{equation}
\begin{array}{l}{\text { if (condition) }} \\ {\text { \{ }} \\ {\text { statement }} \\ {\mathrm{~ \} ~}}\end{array}
\end{equation}
if-else:
If-else statement is used to execute any of the two blocks of statements, if the condition satisfies it executes the statements in the “if block”, otherwise it executes the “else block”.
switch case:
Switch statement is used when a variable is to be checked for equality in a list of values.
_______________________
Iteration
The iterative control structures are used for repetitively executing a block of code multiple times; the following are the basic iterative control structures.
for:
A for loop executes the statements for a specific number of times mentioned in the condition.
while:
A while loop executes statement repeatedly until the condition satisfies.
do-while:
A do-while loop works similar to while loop, the only difference is it executes the statement once before checking the condition.
Work Step by Step
In a program, a control structure determines the order in which statements are executed. The following are the basic control structures in the programming languages: