0% found this document useful (0 votes)
28 views

Flowchart

Uploaded by

safwan1245amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Flowchart

Uploaded by

safwan1245amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Topic: Algorithm Design Using Flowchart

A flowchart is a visual representation or diagram that illustrates the sequence of steps,


decisions, and processes involved in solving a problem, performing a task, or executing
a computer program. It is a widely used tool in computer science and other fields to
provide a clear and structured depiction of how a process works.

R
Flowchart Symbols:

SI
Denotes the start and end of an algorithm.

AN
Denotes a process to be carried out.

AS
IH
Denotes a decision to be made.
ED

Shows the logical flow of the program.


EH

Denotes a subprocess that may be defined in a separate flowchart.


M

Denotes input and/or output.


S
M

Denotes Next page


C

Denotes Previous Page

Mehedi Hasan/ Computer Science/ 01871511834 Page 1 of 21


Exercise: 01
Write an algorithm using flowchart to input three numbers and output their Average.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 2 of 21


Exercise: 02
Write an algorithm using flowchart to input 100 numbers and output their
Average.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 3 of 21


Exercise: 03

Write an algorithm using flowchart to input three numbers and output the
largest of three numbers.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 4 of 21


Exercise: 04
Write an algorithm using flowchart to input three numbers and output the smallest of
three numbers.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 5 of 21


Exercise: 05
Write an algorithm using flowchart to input 100 positive numbers and output the
largest Number.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 6 of 21


Exercise: 06
Write an algorithm using flowchart to input 100 numbers and output the smallest
Number.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 7 of 21


Exercise: 07
Write an algorithm using flowchart to input 100 numbers and output the largest and
smallest Number.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 8 of 21


Exercise: 08
As part of an experiment, a school measured the heights (in metres) of all its 500 students.
Write an algorithm, using flowchart, which inputs the heights of all 500 students and outputs
the height of the tallest person and the shortest person in the school.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 9 of 21


Exercise 9:
Write an algorithm using Flowchart which takes temperatures input over a 100 day period
(once per day) and output the number of days when the temperature was below 20C and
the number of days when the temperature was 20C or above.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 10 of 21


Exercise: 10
A geography class decide to measure daily temperatures and hours of sunshine per day over
a 12 month period (365 days)
Write an algorithm, using Flowchart, which inputs the temperatures and hours of sunshine
for all 365 days, and finally outputs the average (mean) temperature for the year and the
average (mean) number of hours per day over the year.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 11 of 21


Exercise: 11
A small shop sells 280 different items. Each item is identified by a 3 – digit code. All items
that start with a zero (0) are cards, all items that start with a one (1) are sweets, all items
that start with a two (2) are stationery and all items that start with a three (3) are toys.
Write an algorithm, using Flowchart, which inputs the 3 – digit code for all 280 items and

R
outputs the number of cards, sweets, stationery and toys.

SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 12 of 21


Exercise: 12

A company are carrying out a survey by observing traffic at a road junction. Each time a car,
bus, lorry or other vehicle passed by the road junction it was noted down.
10 000 vehicles were counted during the survey.
Write an algorithm, using Flowchart, which:

R
SI
• inputs all 10000 responses
• outputs the number of cars, buses and lorries that passed by the junction during the
survey
• outputs the number of vehicles that weren’t cars, buses or lorries during the survey.

AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 13 of 21


Exercise: 13
A town contains 5000 houses. Each house owner must pay tax based on the value of the
house. Houses over $200 000 pay 2% of their value in tax, houses over $100 000 pay 1.5% of
their value in tax and houses over $50 000 pay 1% of their value in tax. All others pay no tax.
Write an algorithm to solve the problem using Flowchart.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 14 of 21


Exercise: 14
A shop sells books, maps and magazines. Each item is identified by a unique 4 – digit code. All books
have a code starting with a 1, all maps have a code starting with a 2 and all magazines have a code
beginning with a 3. The code 9999 is used to end the program.
Write an algorithm using Flowchart which input the codes for all items in stock and outputs the
number of books, maps and magazine in stock. Include any validation checks necessary.

R
SI
AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 15 of 21


Exercise 15:

R
Using Flowchart or otherwise, write an algorithm that will input the ID, weight (kg) and
height (m) of 30 students, calculate their body mass index (BMI) and output their ID,

SI
BMI and a comment as follows:
A BMI greater than 25 will get the comment ‘OVER WEIGHT’, a BMI between 25 and
19 (inclusive) will get ‘NORMAL’ and a BMI less than 19 will get ‘UNDER WEIGHT’.

AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 16 of 21


Exercise 16:
A company has 5000 CDs, DVDs, videos and books in stock. Each item has a unique
5-digit code with the first digit identifying the type of item, i.e.
1 = CD
2 = DVD

R
3 = video
4 = book

SI
For example, for the code 15642 the 1 identifies that it is a CD, and for the code 30055 the
3 identifies that it is a video.
Write an algorithm, using Flowchart or otherwise, that

AN
• Inputs the codes for all 5000 items
• Validates the input code
• Calculates how many CDs, DVDs, videos and books are in stock
• Outputs the four totals.

AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 17 of 21


Exercise 17:
Customers can withdraw cash from an Automatic Teller Machine (ATM).

• withdrawal is refused if amount entered > current balance


• withdrawal is refused if amount entered > daily limit

R
• if current balance < $100, then a charge of 2% is made
• if current balance $100, no charge is made

SI
Write an algorithm which inputs a request for a sum of money, decides if a withdrawal can
be made and calculates any charges. Appropriate output messages should be included.

AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 18 of 21


Exercise 18:
A small airport handles 400 flights per day from three airlines:

FASTAIR (code FA)


SWIFTJET (code SJ)

R
KNIGHTAIR (code KA)

Each flight is identified by the airline code and 3 digits. For example FA 156.

SI
Write an algorithm, using pseudocode or otherwise, which monitors the 400 flights into and
out of the airport each day. The following inputs, processing and outputs are all part of the
monitoring process:

AN
• input flight identification
• calculate number of flights per day for each of the three airlines
• output the percentage of the total flights per day by each airline
• any validation checks must be included.

AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 19 of 21


Exercise 19:
A school has 1800 students. The start date and leaving date for each student is stored on file. Dates are in
the format YYMMDD (e.g. a student starting on 10th September 2007 and leaving on 4th August 2012 has
the data 070910 and 120804 on file).
Write an algorithm, using pseudocode orotherwise, which
• inputs Student ID for all 1800 students
• inputs the start date and leaving date for each student

R
• carries out a check to ensure the second date is later
• if error, increments error counter

SI
• outputs the number of errors

AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 20 of 21


Exercise 21:
A greenhouse is being monitored by a computer using 2 sensors. SENSOR1 measures the temperature and
SENSOR2 measures oxygen levels.
If the temperature exceeds 45°C or oxygen levels fall below 0.19, then an error
message is output by the computer.
Write an algorithm, using pseudocode or flowchart only, which
• inputs both sensor readings

R
• checks the sensor input values and outputs a warning message if either are out of
range

SI
• continues monitoring until the <ESCAPE> key is pressed
(You may assume that READ SENSORn will take a reading from SENSORn and that
READ KEY inputs a key press from the keyboard).

AN
AS
IH
ED
EH
M
S
M
C

Mehedi Hasan/ Computer Science/ 01871511834 Page 21 of 21

You might also like