In a sequence structure or sequential structure, the statements of a program are executed in the same order in which they are written in the program. The statements are executed one after the other. In this structure, all statements of the program executed sequentially without skipping any statement.
An algorithm with sequence structure are as follows:
In the above diagram, the first statement is “Statement-1” and “Statement-n” is the last statement that will be executed in a sequence from top to bottom (such as from statement-1 to statement-n).
Example Program of C++ Sequence Structure:
The following source code of the program execute statement one by other and displays result on the screen.
cout << "First statementn";
cout << "Second statementn";
cout << "Third statementn";
cout << "Forth statementn";
}//end main function
If you run this program, the output will be as follows: