0% found this document useful (0 votes)
44 views2 pages

Chapter 7 Algorithms W6

This document contains 5 questions about algorithms and programming concepts. Question 1 asks for examples of test data for a program that checks melon weights. Question 2 identifies errors in a program that finds the smallest of 10 input numbers. Question 3 provides a flowchart and asks to complete a trace table and identify issues. Question 4 asks to write algorithms to input numbers into an array using different loop structures. Question 5 asks to write a program that inputs patient data, calculates BMI, and outputs various results.

Uploaded by

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

Chapter 7 Algorithms W6

This document contains 5 questions about algorithms and programming concepts. Question 1 asks for examples of test data for a program that checks melon weights. Question 2 identifies errors in a program that finds the smallest of 10 input numbers. Question 3 provides a flowchart and asks to complete a trace table and identify issues. Question 4 asks to write algorithms to input numbers into an array using different loop structures. Question 5 asks to write a program that inputs patient data, calculates BMI, and outputs various results.

Uploaded by

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

Chapter 7 – Worksheet 6

1. A routine checks the weight of melons to be sold in a supermarket. Melons weighing under 0.5
kilograms are rejected and melons weighing over 2 kilograms are also rejected.
Give an example of each type of test data for this routine.

Normal ......................................................................................................................................
Extreme ....................................................................................................................................
Abnormal .............................................................................................................................. [3]

2. Read this section of program code that should input 10 positive numbers and then output the
smallest number input. [4]
1 Small = 0
2 Counter = 0
3 REPEAT
4 INPUT Num
5 IF Num < Small THEN Num = Small
6 Counter = Counter + 1
7 PRINT Small
8 UNTIL Counter < 10
There are four errors in this code.
Locate these errors and suggest a corrected piece of code for each error.

3. The flowchart below inputs six single digit numbers. The predefined function MOD gives the value
of the remainder, for example, Y ← 10 MOD 3 gives the value Y = 1 [4]
Complete a trace table for each of the two sets of input data.
Set 1 5, 2, 4, 3, 1, 5
Set 2 3, 2, 1, 0, 7, 3
Trace table set 1 5, 2, 4, 3, 1, 5

(b) State the purpose of the flowchart in part (a). [1]


(c) Identify a problem with this flowchart and explain how to correct it. [3]
Problem
Solution

4. (a) Write an algorithm, using pseudocode and a FOR … TO … NEXT loop structure, to input 1000
numbers into an array. [2]
(b) Rewrite your algorithm using another loop structure. [3]

5. Using pseudocode, write an algorithm that will input the ID, weight (kg) and height (m) of 30
patients in 3 separate 1D arrays, calculate their body mass index (BMI) and prints for each patient.

BMI = weight / (height)2


A BMI greater than 25 is considered overweight and a BMI less than 19 is underweight.

Output the IDs of patients who are overweight.


Output the IDs of patients who are underweight.
Output the average BMI for all 30 patients.
Output the ID of the patient with the highest and lowest BMI. [10]

----xxxxx-----

You might also like