This preview shows page 1. Sign up to view the full content.
Unformatted text preview: counting we make some error then
the logic will not work. If the supplied number is less than the actual number of input
records, then the computer will not process the data for last few students. And if the
supplied number is more than the actual number of input records, the computer will try to
read more records than what is supplied which will cause an error in the logic.
Read input data
Add marks of all subjects giving Total
Percentage = Total 110
Write output data
Read input data
The second drawback is that the flowchart of Figure 11.6 is not a generalized solution to
the given problem. Suppose the examination is conduced every year and so we will like
to use the same program every year to process the students' data. However, the number of
students appearing in the examination may not remain the same every year. This year it
may be 50, but next year it can be 55 or 60 or anything. So if the computer program to
solve this problem was based on the flowchart of Figure 11.6, the statement concerned
with the decision step in that program will have to be changed again and again to supply
the exact number of students. This is not a good programming practice. We saw that a
good algorithm (program) should be general in nature. For example, in this case we
should write a program that need not be modified every time even if the total number of
The flowchart of Figure 11.6 suffers from these drawbacks because in this flowchart the
process loop is being controlled by counting. When the loop has been executed 50 times,
the decision will cause execution to proceed to the "Stop", thus terminating processing.
(The reader should carefully step through the logic to ensure that the loop will be
executed exactly 50 times and not 49 or 51 times). To avoid these drawbacks, another
method can be adopted to control the process loop. In this method, the end of input data
is marked by a trailer record that is the last data record in the input is followed by a...
View Full Document
- Spring '14