Control Statements in C++

Usually a program is not a linear sequence of instructions. It may repeat code or take decisions for a given path-goal relation. Most programming languages have control flow statements (constructs) which provide some sort of control structures that serve to specify order to what has to be done to perform our program that allow variations in this sequential order.The flow of execution of statements in a program is called as control. Control statement is a statement which controls flow of execution of the program. Control statements are classified into following categories.

  1. Sequential control statements
  2. Conditional control statements
  3. Unconditional control statements

1. Sequential control statements

statements ensures that the instructions(or statements) are executed in the same order in which they appear in the program. i.e. By default system executes the statements in the program in sequential order.

2. Conditional control statements

A conditional is a statement that instructs the computer to execute a certain block of code or alter certain data only if a specific condition has been met. Statements that are executed when a condition is true. These statements are divided into three categories.

  1. Decision making statements
  2. Switch case control statement or
  3. Loop control statements or repetitions

3. Unconditional control statements

Statements that transfers control from on part of the program to another part unconditionally are called unconditional control statements.

  1. goto
  2. break
  3. continue

Related posts