The sequential control flow structure can be pictorially portrayed as shown below.
Sequential programming can also be called linear programming. The sequential programs non-modular in nature, that is, reusability o code is not possible. Thus, they are difficult to maintain and understand.
Consider an example of finding the circumference and area of a circle. The circumference of a circle is given by the formula 2*pi*r and the area of the circle is found out using the formula pi*r*r, where r is the radius of the circle and pi is a constant. Thus, in this Case. the objective is simple. That is, the tasks that are to be performed include.
Here, one can understand that the objective is clear and therefore, the program will have statements Also, that are placed sequentially and there is no decision involved in the process. the program does not require a specific task to be repeated over and over again.
Example 2.1
This example shows how the circumference and area of sequential programming construct works. Here, a circle is determined.
#include <stdio.h>
int main()
{
float radius, circumference, area;
float pi=3.1416;
printf ("Enter value for radius \n");
scanf ( "%f", &radius) ;
circumference = 2 * pi * radius;
area = pi * radius * radius;
printf ("The circumference of the circle is %f", circumference);
printf ("The area of the circle is %f", area);
}
The selective control structure can be illustrated in the following way.