Flowcharting Part
Flowcharting Part
Flowcharting Part
FLOWCHARTS
Question 1
Draw the program flowchart for finding the
sum of first 100 odd numbers.
Solution 1
Start
Clear all working
Locations
Set A=1
B = B+A
A = A+2
No
?
A=
199
Yes
Print B
Stop
Step 4:
Since we have to stop at the 100th
terms which
is equal
to 199,
Step
0:
step
4 poses
a question.
Has A
Use
START
to start
a flowchart
1 :go back to step
become 199 ?Step
If not,
All working
locations
are
set at
zero.
3 by forming
loop.
Thus,
A is
This
is necessary
because
repeatedly
incremented
in stepif 5they
and
areadded
holding
some
of the
the
to B inStep
step2:3.data
B holds
A is set atprogram,
1sum
so that
subsequently
by
previous
that
is liable
cumulative
upto
thedata
latest
terms
incrementing
it successively
by199
2,
toheld
corrupt
result
of the
flowchart.
in A.the
When
A has
become
wethat
get means
the wanted
odd terms :
the necessary
Step
3:
1,3,5,7
computations
have etc.
been
carried out
Asoisthat
poured
into6Bthe
i.e.,
added
to B. B
in step
result
is printed.
being 0 at the moment and A being
1, B becomes
0 + 1 = 1.
Step 5:
we shall increment A by 2. So that
although at the moment A is 1, it will
be made 3 in step 5 , and so on.
Step 6 :
Result is Printed
Question 2
There are three quantities; Q1 Q2 and Q3. It is desired to
obtain the highest of these in location H and lowest of
these in location L.
Solution 2
Step 0
All working locations are
assigned
Step 2toZero
Any two quantities, say Q1 and
Q2 are compared. If Q1 is
greater than Q2.
Start
Clear all working
Locations
Read Q1,
Q2 and Q3
Yes
?
Q1 > Q2
No
H = Q1
H = Q2
L = Q2
L = Q1
Step 1
The three quantities Q1,
Q2 and Q3 are read in via,
say, these values are
entered
through
keyboard
a
Steps
3B andof4B
terminal.
Alternatively
we can make H =
Q1 and L = Q2 in
Steps 3A and 4A,
we make H = Q2 and L = Q1.
No
?
Q3 < L
?
Q3 > H
Yes
No
H = Q3
Step 5,
we are holding the
higher of Q1 and Q2 in H
and the lower of these in
L. We see if Q3 is
greater than H.
Yes
L = Q3
Step 8
If its a Yes, H is made
equal to Q3.
Stop
Step 6
If Q3 is not greater than
H, we compare Q3 with
L 7
Step
if Q3 < L, we make L =
Q3, otherwise, the job
has already been
done prior to Step 5.
Question 3
Draw the flowchart for deriving the sum of the
squares of first 20 odd numbers.
Solution 3
Start
Clear all Working
Locations
Set K = 1
Square = K * K
C =C + Square
K=K+
2
No
?
K = 39
PRINT
C
END
Yes
Step 0
All working locations
are assigned the value
Step 1
zero
The first odd number
is 1 soStep
we set
2 K=1
The square of first odd
number is computed
by multiplying K with K
and the result so
obtained is stored in
Step
3
location
SQUARE.
We accumulate the
4
first termStep
i.e. square
of
The
20th
odd
number
the first odd number 1is
39, therefore
in this
in location
C. step
we see if K has become 39
5
or notStep
(by step
5)
K is increment by 2 i.e.
it becomes 1+2 = 3
Question 4
The weights of newly born babies in a hospital are input to
computer. The hospital in charge is interested to find the
maximum, minimum and mean weights of all the weights
of the babies. Draw a suitable flow chart for his problem. A
value of zero can be used at the end of the list of baby
weights. This denotes the end of the list.
Solution 4
START
INPUT W
MINW = W
MAXW = W
TOTW = W
COUNT = 1
INPUT W
IS
W=0?
Yes
MEANW=TOTW/C
OUNT
PRINT
MAXW, MINW,
MEANW
No
IS
W<
MINW
?
Yes
MINW=W
END
No
IS
W>
MAXW
?
Solution 4 (2)
Yes
No
TOTW=TOTW W
COUNT=COUNT + 1
MAXW=W
Class of Goods
1
2
3
4
Foods, beverages
Clothing, footwear
Heavy machinery
Luxury items
10
15
17.5
40
START
Solution 5
Input Value,
Class no, V, K
No
?
K=1
Yes
?
K=2
Yes
DUTY =
V * 0.1
No
No
?
K=3
DUTY =
V * 0.4
Yes
DUTY =
V * 0.15
DUTY =
V * 0.175
Print
DUTY
Last
Item?
No
Yes
END
Question 6
A bicycle shop in Delhi hires bicycles by the day at different
rates as shown in the following table :Season
8.00
9.50
5.00
6.00
START
Solution 6
Yes
RATE = 8.00
No
SEAS =
Summer
Yes
RATE = 9.50
No
SEAS =
Autumn
No
RATE = 5.00
Yes
SEAS =
Winter
No
Yes
RATE = 6.00
Solution 6 (2)
Yes
Print
Invalid Seas
DAY >10
No
NRT = Rate
B
HCHG = Days * NRT
TCHG = HCHG +20.00
No
N >=25
Yes
END
Print
NAME, DAYS,
HCHG, TCHG
Question 7
Prices for ten commodities in the current year are
designated by J(X), X varying from 1 to 10. Likewise,
their last years prices are designated by K(Y), Y
varying from 1 to 10. Draw the flowchart for finding the
number, N of commodities of which prices have
increased.
Solution 7
START
Clear all working locations
Set X = 0
Set Y = 0
Increment X by 1
Increment Y by 1
No
?
No
X=10
Yes
Print N
END
?
J (X)>
K(Y)
Yes
N=N+1
Question 8
Add 45 (a constant) to the wages of 10 persons
designated by J(X), X = 1,2...10
Solution 8
START
Clear all working locations
Set X = 0
Increment X by 1
J (X) = J(X) + 45
No
?
X=10
Yes
END
Question 9
Print 6 Ps in the pattern given below
012(print position)
p
p
p
p
p
p
007 (print position)
Solution 9
START
Clear all working locations
Set Y = 13
Decrement Y by 1
1 Line CS Feed
Print P at Y
No
?
Y=7
Yes
END
Question 10
In locations J(X), X = 1, 2....200 are held 200 quantities.
Draw flowchart for finding the ratio of the total number
of quantities indivisible by 10 to that of divisible by 10.
Solution:
The following symbols are used in it.
NONTEN
Total number of items not divisible by 10
TENNER
Total number of items divisible by 10
RATIO
Ratio NONTEN/TENNER
J(X), X = 1,2...200 are used to hold the last digit of a quantity.
Partial transfer (as we have down in this flowchart) of one or more
consecutive digits from one location into another location is valid.
START
Solution 10
Set X = 0
Increment X by 1
Transfer last digit of
J(X) in J
No
Yes
J=0
Increment
NONTEN by 1
No
Increment
TENNER by 1
?
X=200
Yes