# Algorithms and Flowcharts

## Fill in the blanks

#### Question 1

The first symbol in a flowchart is the START symbol.

#### Question 2

A flowchart is a pictorial representation of a sequence of instructions that are required to solve a problem.

#### Question 3

Flow lines are used to connect different boxes.

#### Question 4

The Decision Box is used for making decisions as well as comparisons.

#### Question 5

All mathematical operations are put in a Process box.

## Complete the following flowcharts

#### Question 1

A flowchart to check whether a triangle is possible or not. #### Question 2

A flowchart to display the greater of the two numbers. ## Write algorithms for the following

#### Question 1

To go for a class picnic

Step 1: Start
Step 2: Decide the picnic venue, date and time
Step 3: Decide the picnic activities
Step 4: Hire a vehicle to reach to the venue and comeback
Step 5: Goto to the picnic venue on the decided date
Step 6: Do the activities planned for the picnic
Step 7: Come back to school in the hired vehicle
Step 8: Stop

#### Question 2

To celebrate New Year

Step 1: Start
Step 2: Prepare a guest list for New Year party
Step 3: Decide the venue, food menu, games and fun activities for the party
Step 4: Invite the guests for the party
Step 5: On New Year eve, get ready and enjoy the party
Step 6: Stop

#### Question 3

To make tea/coffee

Step 1: Start
Step 2: Boil water in a saucepan
Step 3: Add tea to boiling water
Step 4: Add sugar to boiling water
Step 5: Add milk to boiling water
Step 6: Boil this water with all the ingredients for 2 mins
Step 7: Sieve the tea in a cup
Step 8: Stop

#### Question 4

To celebrate Teachers' Day

Step 1: Start
Step 2: Decide the activities for teachers' day like dance performances, plays, etc.
Step 3: Form groups of students and assign the decided activities from step 2 to each group.
Step 4: Decide the practice timings for each group.
Step 5: Each group to practice as per the timings decided in step 4.
Step 6: Invite the teachers to Teachers' Day celebrations.
Step 7: Perform the activities planned in step 2 on Teachers' Day
Step 8: Stop

#### Question 1

What is a flowchart? What are the features of a flowchart?

A flowchart is a pictorial representation of an algorithm. It uses boxes of different shapes to represent different types of instructions. These boxes are connected with arrow marks to indicate the flow of operations.

The features of a flowchart are:

1. It is an easy method of communication.
2. It is independent of a programming language.
3. It is the key to correct programming.
4. It helps to plan and design a new system.
5. It clearly indicates the task to be performed at each level.

#### Question 2

What is an algorithm? What are its characteristics?

An algorithm is defined as the sequence of instructions written in simple English that are required to get the desired results. It helps to develop the fundamental logic of a problem that leads to a solution.

Some characteristics of an algorithm are as follows:

1. Each step of an algorithm must be precisely defined.
2. An algorithm must contain blocks that will help to solve problems more efficiently and logically.
3. It should accept a set of inputs and produce a defined output.
4. It must be terminated after a finite number of steps.
5. It should be independent from a computer programming language.
6. It should develop a platform for writing programs.

#### Question 3

Define the following and draw their symbols:

(a) Process Box

A process box is used to represent all types of mathematical tasks like addition, subtraction, multiplication, division, etc. (b) Terminal Box

Terminal Box is used to indicate the beginning (START) and the end (STOP) of a flowchart. A terminal box with the word 'START' is used at the beginning and a box with the word 'STOP' is used at the end of a flowchart.  (c) Input/Output Box

Input/Output Box is used to represent an input/output operation of a task. Statements like INPUT, PRINT, etc. are used in these boxes. (d) Decision Box

Decision Box is used to check a condition in a flowchart. The Decision Box has two paths, one if the condition is true and the other is the condition is false. ## Write algorithms and draw flowcharts for the following

#### Question 1

Accept the length of two different line segments and check whether they are equal or unequal. Display the message accordingly.

Algorithm

Step 1: Start
Step 2: Accept the length of the two line segments as l1 and l2.
Step 3: If l1 and l2 are equal, then display 'Line Segments are equal'.
Step 4: If l1 and l2 are not equal, then display 'Line Segments are not equal'.
Step 5: Stop

Flowchart #### Question 2

Accept the age of a person and check whether he/she is eligible to vote or not. A person is eligible to vote only when he/she is 18 years or more.

Algorithm

Step 1: Start
Step 2: Accept the age of the person.
Step 3: If age is greater than or equal to 18, then display 'You are eligible to vote'.
Step 4: If age is less than 18, then display 'You are not eligible to vote'.
Step 5: Stop

Flowchart #### Question 3

Accept three numbers and check whether they are 'Pythagorean Triplets' or not. Display the message accordingly.
(Hint: Use Pythagoras Formula for a Right-angled Triangle: h = p2+b2)

Algorithm

Step 1: Start
Step 2: Take 3 numbers as input (Say A,B,C)
Step 3: If A2 = B2 + C2, display 'Pythagorean Triplets'
Step 4: If B2 = A2 + C2, display 'Pythagorean Triplets'
Step 5: If C2 = A2 + B2, display 'Pythagorean Triplets'
Step 6: If no condition of Step 3,4,5 match, display 'Not Pythagorean Triplets'
Step 7: Stop

Flowchart ## Draw flowcharts for the following

#### Question 1

Accept the name and marks obtained by a student in Computer Project. Display the grades as per the table given below:

80% or moreA
60% or more but less than 80%B
40% or more but less than 60%C

Flowchart #### Question 2

Input three angles of a triangle and check whether a triangle is possible or not. If possible, then check whether it is an 'Acute-angled Triangle, 'Obtuse-angled Triangle' or a 'Right-angled Triangle'.

Flowchart #### Question 3

Accept a number and check:

(a) whether the number is divisible by 2 and 5.
(b) whether the number is divisible by 2 but not by 5.
(c) whether the number is divisible by 5 but not by 2.
Display the message accordingly

Flowchart #### Question 4

Input the quantity purchased and the rate. Calculate the total purchase price and display it along with the gift to be presented. The gifts to the customers are given as under:

100 and above but less than 500A key ring
500 and above but less than 1000A leather purse
1000 and aboveA pocket calculator

The flowchart will end with a 'Thank you' message.

Flowchart #### Question 5

A librarian charges a fine for books, if returned late. The tariff for the fine is given below:

No. of daysFine
For the first ten days40 paise per day
Eleven to twenty days60 paise per day
More than twenty days80 paise per day

Draw a flowchart to calculate the fine assuming that a book is returned 'N' days late.

Flowchart 