Filed under
Flowchart
,
on
Tuesday, January 26, 2010
In preparing flowcharts for complex problems:
• The flowchart may not fit in a single page.
• It may be difficult to interconnect all boxes directly.
In such cases, flowcharts can be broken into parts and connectors can be used to indicate the location of the joins. If the example in Figure 4 is split it will be as shown in Figure 9.
A unique number is specified within the connector and an arrow is drawn into it at the point where the chart is broken. Another connector with the same number and an arrow pointing away from it is drawn at the point where the broken chart is to be joined again.
Connectors are inserted at the point where the flowchart splits. However, the location of each join is clearly indicated by the corresponding number.
Tips for Flowchart
The following points are to be remembered while drawing a flowchart:
• Initially concentrate on the logic of the problem and draw the main path of the flowchart.
• After the main part is completed, add all the branches and loops.
• A flowchart can have only one Start point and one Stop point.
• As far as possible, keep the flowchart machine independent by not using terms associated with the computer.
• It is not necessary to represent each and every step of a program in the flowchart. Use steps that are meaningful.
• Use descriptive terms that represent the logic of a problem. Do no use ambiguous terms.
• Remember that another user or programmer should easily understand the flowchart.
Figure 9
Filed under
Flowchart
,
on
Monday, January 25, 2010
Looping refers to using one or more steps repeatedly.
Loops are of two types:
• Fixed
• Variable
Consider the following examples to understand the two different types of looping:
Example 4
To calculate the sum of monthly expenditure for an entire year, the flowchart is as follows in Figure 6. Figure 6 illustrated a fixed loop because the total number of months in a year is 12. Thus, this loop cannot be executed for more than 12 times.
We consider the expenditure of one month at a time and add it to the total expenditure. After the expenditure of each month is added to the total expenditure, we examine whether the number of months is equal to 12.
Figure 6
If ‘Yes’ then there are no more months left and we display the total expenditure and stop. If ‘No, we accept the expenditure of the next month.
Since the number of the months in a year is fixed, this loop cannot be executed more than 12 times. Hence, this is an example of a fixed loop.
Example 5
Another example, a survey is carried out in a town. Information such as the name, sex, age etc. of each person is available. To maintain a list of people aged 50 and above in the town we draw a flowchart as follows:
Figure 7
Figure 7 illustrates a variable loop as we do not know the exact number of people in the town. This loop continues till the name and age of the last person in the town is read.
Given below is the basic flowchart for a loop.
Figure 8
Loops are fixed if operations are repeated a fixed number of times. The values being computed or handled inside the loop have no effect on the number of times the looping operation is done.
Variable loops are the ones where the operations are repeated until a specified condition is met. The number of times that the loop is repeated may vary.
Filed under
Flowchart
,
on
Monday, January 25, 2010
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.
Filed under
Flowchart
,
on
Monday, January 25, 2010
A flowchart is a diagrammatic representation that illustrates the sequence of operations to be performed to arrive at a solution. In other word, Flowchart helps us to understand and see the form of algorithms by representing algorithms in picture symbols.
The instructions are depicted using the specific symbols. These symbols are connected by arrows to indicate the order of execution.
Figure 1
Flowcharts are tools used to write programs and they serve the following purpose:
• They are easier to understand, at a glance, than a narrative description.
• We can review and debug programs easily with the help of flowcharts.
• They provide effective program documentation.
• With a flowchart drawn, it is easier to explain a program or discuss a solution.
In drawing flowcharts, certain symbols are used. They are as shown in Figure 1.
The following example will help us to understand the use of the different symbols in a flowchart:
Example 1 To find the sum of the two numbers, the flowchart will be as follows:
Figure 2
The flowchart shown in Figure 2 illustrates the steps in a straight-line logic. It involves no repetitions or alternate sequence or steps. But, in practice:
- Repeating certain steps of a program is common
For example, calculating the average marks for 100 students. The step that calculates the average for one student has to be repeated 100 times.
- We take an alternate sequence of steps for some situations
For example, if the amount in a bank account is greater than the withdrawal amount then the withdrawal is processed. If the amount is less then the withdrawal is refused.