Explain the control statement with a suitable example.
Control statements are statements that alter the sequence of flow of instructions.
In a program, statements may be executed sequentially, selectively, or iteratively. Every programming language provides statements to support sequence, selection (branching), and iteration.
The selection statement means the statement(s) are executed depends upon a condition. If a condition is true, a true block ¡s executed otherwise a false block is executed. This statement is also called a decision statement or selection statement because it helps in making decisions about which set of statements are to be executed.
The iteration statement is a set of the statement are repetitively executed depends upon conditions. If a condition evaluates to true, the set of statements (true block) is executed again and again. As soon as the condition becomes false, the repetition stops. This is also known as a looping statement or iteration statement.