Simple for Next Loop (Format 1) Notes With Practice Questions
Simple for Next Loop (Format 1) Notes With Practice Questions
NOTE: Do Your Assignment Work in School Registers, Every Assignment carries 1 mark, if all Assignments will be submitted on time, and 1 bonus
mark will be awarded.
Firstly, Let us revise the whole concept by solving the first part given below
Solved Example
What would be the Fuel Economy of a car travelling 40 km on 10 liters of fuel? [1]
(b) The Fuel Economy for 1000 cars is to be calculated using the formula in Question 16(a).
Write an algorithm, using pseudo code or otherwise, which inputs the Distance Travelled (km) and the Fuel Used (liters) for 1000 cars. The Fuel
Economy for each car is then calculated and the following outputs produced:
Solution
As we know that:
Format 1
Initialize
Input
Formula Calculation
Extreme values
Next Count
Output average
Output percentage
>>>>>>>>>>>>>>>>>>>>>>>>>>>
Now we know the format 1, we’ll write the pseudo code for the above problem (b part) according to Format 1 and we’ll also mention which part
of Format 1 is correlating with the Pseudo Code.
Fuel_economy <- 0
Input distance
Endif
Next Next
Avg <- total/1000 average <- total/N
Note that not all of the contents of format 1 are correlated with the pseudo code, as they were not required. Only desired contents should be
used, which we can obtain by carefully reading the problem.
Assignment Questions,
Q.1 Correlate the Format 1 with the solved ‘b’ part of the problem given below. (Hint: look at the above given example)
(a) A formula for calculating the body mass index (BMI) is:
Calculate the BMI for a person whose weight is 80kg and height is 2 metres. [1]
(b) Using pseudocode 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,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’.
Solution
weight <- 1
height <- 1
bmi <- 0
Output ‘OVERWEIGHT’
Endif
Output ‘NORMAL’
Endif
Output ‘UNDERWEIGHT’
Endif
NEXT
Q.2 Correlate the Format 1 with the solved part of the problem given below.
Temperatures (°C) are being collected in an experiment every hour over a 200 hour period. Write an algorithm, using pseudo code or otherwise,
which inputs each temperature and outputs
Solution
temp <- 0
totalhigh <- 0
totallow <- 0
Input temp
Endif
Endif
Endif
Next
Output totalhigh
Output totallow
Output lowest
Now, solve these Problems given below all by yourself With the Help of Format 1.
Q3
(a) A car’s speed is measured between points A and B, which are 200 km apart.
(b) Write an algorithm, using pseudo code, which inputs the times for 500 cars, calculates the final speed of each car using the formula in part
(a), and then outputs:
Q4
A school is doing a check on the heights and weights of all its students. The school has 1000 students.
• inputs 50 numbers
• outputs how many of the numbers were > 100