The computing we do
is independent of the computer language we use. It does not depend on the
computer also. The choice of the computer and the language mostly depend on
their suitability for the given situation. While developing a program, we think
only in the natural languages like Tamil and English. Only at the last moment
the design is converted into a program in a high level language.
In the computer
languages every statement must be written precisely, including commas and
semicolons. One has to be very careful while writing these lines. In the
natural languages the sentences may be long. Sometimes they may be vague. All
the natural languages have this property. So, to understand things clearly
without any ambiguity, we write it in an intermediary language. This will be
easy to write and understand, and also without any ambiguity. These intermediate
languages are in between the natural languages and the computer languages. We
shall study two such intermediate languages, namely, the flow chart and the
pseudo code, which are widely used.
First let us consider
the flow chart. Since the flows of computational paths are depicted as a
picture, it is called a flow chart. Let us start with an example. Suppose we
have to find the sum and also the maximum of two numbers. To achieve this,
first the two numbers have to be received and kept in two places, under two
names. Then the sum of them is to be found and printed. Then depending on which
one is bigger, a number is to be printed. The flow chart for this is given in
flow chart 1. In the flow chart, each shape has a particular meaning. They are
given in flow chart 2.
In the flow chart mentioned
above, there is a special meaning in writing C = A + B. Though we use the
familiar equal to sign, it is not used in the sense as in an equation. This
statement means — Add the current values available for the names A and B, which
are on the RHS, and put the sum as the new value of the name C, which is in the
LHS.
For example, under this explanation, A
= A + 1 is a valid statement. The value of A is taken, incremented by one and
the new value is stored as A. That is, the value of A gets incremented by 1.
Note that we can write A = A + B, but not A + B = A. On the LHS there must be
only a name of a place for storing.
We can write all the
computations we can do with the computers as flow charts. If the problem is
small, the flow chart is also small. What about big problems? Real life
problems are always very big. Only the class room problems are small, as they
are meant to teach some particular concepts within limited time. For big
problems, the flow chart will also be big. But our paper sizes are limited. We
may need many pages for one flow chart. But how to go from one page to another?
This is solved by using small circles, called connectors. In this circle, we
put some symbol. All connectors having the same symbol represent the same
point, wherever they are, whether they are in the same page or on different
pages. Flow chart 3 gives an example.
The advantages of the
flow charts are:
- They are precise. They represent our thoughts exactly.
- It is easy to understand small flow charts.
The disadvantage is
that real life flow charts can occupy many pages, and hence very difficult to
understand. So no one uses flow charts in such situations.
Consider the small
flow charts given for the following problems. See whether they will solve the
problems. Do not memorize them. Try to understand them. Note how much we have
to think before writing a program.
Flow chart 4
estimates the volume of a box using its length, breadth and height.
No comments:
Post a Comment