Branching (Flowchart Part 2)

Filed under , on Monday, January 25, 2010

1

Branching is the process of following one of two of more alternate paths of computations.
To understand branching, consider the following examples:
Example 2   
We want to test if a number is odd or even. To accomplish this, we draw a flowchart following the steps given in the algorithm. This flowchart is shown in Figure 3.

Figure 3




Example 3   
To choose the largest of three distinct numbers a, b and c, the flowchart will be drawn as shown in Figure 4.

Figure 4

Thus, branching is used in a flowchart when we want to represent the testing of a condition. A particular path is selected based on the result of the test. The condition could be a comparison of positive or negative values.
The general form of the flowcharts involved in branching are as follows:

Figure 5

In Figure 5(i), one branch consists of one or more computational steps and the other branch is without any computations. Both the branches join the main program at the end.
In Figure 5(ii), after the decision stage, each branch consists of one or more computational steps. The two branches may then join the main program or take a different path only to join the main program at the end.

Comments Posted (1)

Can flowchart branches cross lines. I mean is yes side cross with no side will it affect the balance of the chart?

Regards,
Creately

Post a Comment