You are on page 1of 4

Manarat Dhaka International School & College

Sample Questions and Answers


Class 8
Subject: Computer Studies
Chapter #7: Algorithm design and problem solving

1 State three methods used to design and construct a solution to a problem.


Answer:
Three methods that can be used to design and construct a solution to a problem are:
a) structure diagrams
b) flowcharts
c) pseudocode.
2 What is structure diagram? Draw a structure diagram for an alarm app computer system for a smart
phone.
Answer:
Structure diagrams a diagrammatic representation of showing how a computer system solution can
be divided into sub-systems with each level giving a more detailed breakdown.
A structure diagram for an alarm app computer system for a smart phone is shown below:

3 What is a flowchart? Draw and explain the standard symbols used in flowchart.
Answer:
A flowchart diagrammatic representation of the steps required to complete a task and the order that
they are to be performed.
Standard flowchart symbols:
Begin/End
Terminator flowchart symbols are used at the beginning and end of each flowchart.

Process
Process flowchart symbols are used to show actions, for example, when values are assigned to
variables.
2

Input and output


The same flowchart symbol is used to show the input of data and output of information.

Decision
Decision flowchart symbols are used to decide which action is to be taken next.

Flow lines
Flowchart flow lines use arrows to show the direction of flow, which is usually, but not always, top to
bottom and left to right.

4 What is pseudocode? State different types of statements used in pseudocode and give example of
each.
Answer:
Pseudocode is a method of showing an algorithm that describes what the algorithm does by using
English key words that are very similar to those used in a high-level programming language.
Assignment statement
A value is assigned to an item/variable using the ← operator. The variable on the left of the ← is
assigned the value of the expression on the right.
Examples of pseudocode assignment statements:
Cost ← 10 Cost has the value 10
Price ← Cost * 2 Price has the value 20
Selection/conditional statement
There are two types of conditional statement:
(a) a condition that can be true or false such as: IF … THEN … ELSE … ENDIF
Example:
IF Age < 18
THEN
OUTPUT "Child"
ELSE
OUTPUT "Adult"
ENDIF
(b) a choice between several different values, such as: CASE OF … OTHERWISE … ENDCASE
Example:
CASE OF Grade
"A" : OUTPUT "Excellent"
"B" : OUTPUT "Good"
"C" : OUTPUT "Average"
OTHERWISE OUTPUT "Improvement is needed"
ENDCASE

Prepared by: Md. Monirul Islam


3

Looping/iteration/repetition statement
Pseudocode includes these three different types of loop structure:
A set number of repetitions FOR … TO … NEXT
A repetition, where the number of repeats is not known, that is
REPEAT … UNTIL
completed at least once:
A repetition, where the number of repeats is not known, that may
WHILE … DO …ENDWHILE
never be completed:

Example of FOR … TO … NEXT loop


FOR Counter ← 1 TO 10
OUTPUT "Enter Name of Student "
INPUT StudentName
NEXT Counter
Example of REPEAT … UNTIL loop
Total ← 0
Mark ← 0
REPEAT
Total ← Total + Mark
OUTPUT "Enter value for mark, -1 to finish "
INPUT Mark
UNTIL Mark = -1
Example of WHILE … DO … ENDWHILE loop
Total ← 0
OUTPUT "Enter value for mark, -1 to finish "
INPUT Mark
WHILE Mark <> -1 DO
Total ← Total + Mark
OUTPUT "Enter value for mark, -1 to finish"
INPUT Mark
ENDWHILE
5 Write an algorithm in the form of flowchart that inputs two numbers and outputs the largest number.
Answer:

Prepared by: Md. Monirul Islam


4

6 Write an algorithm in the form of pseudocode that inputs 100 numbers and outputs the total of the
numbers.
Answer:
Total ← 0
FOR Counter ← 1 TO 100
INPUT Num
Total ← Total + Num
NEXT Counter
OUTPUT “Total of the numbers is:”, Total
7 Write an algorithm in the form of pseudocode that inputs 100 numbers and outputs the average of
the numbers.
Answer:
Total ← 0
FOR Counter ← 1 TO 100
INPUT Num
Total ← Total + Num
NEXT Counter
Avg ← Total / 100
OUTPUT “Average of the numbers is:”, Avg
8 Write an algorithm in the form of pseudocode that inputs 100 numbers and outputs the number of
positive numbers and the number of negative numbers.
Answer:
PosCount ← 0
NegCount ← 0
FOR Counter ← 1 TO 100
INPUT Num
IF Num > 0
THEN
PosCount ← PosCount + 1
ELSE
IF Num > 0
THEN
NegCount ← NegCount + 1
ENDIF
ENDIF
NEXT Counter
OUTPUT “Number of positive numbers is:”, PosCount
OUTPUT “Number of negaitive numbers is:”, NegCount

Prepared by: Md. Monirul Islam

You might also like