Docsity

pseudocode pracitce questions, Exercises of Computer science

Toggle sidebar
bg1
Question 1
Question 2: Write an algorithm, using pseudocode or a program flowchart only, which:
• inputs the population and land area for 500 countries,
• calculates the population density (i.e. population/land area) for every country,
• outputs the largest and smallest population density,
• outputs the average population for all 500 countries.
Question 3: A school is doing a check on the heights and weights of all its students. The
school has1000 students. Write an algorithm, using pseudocode which,
• inputs the height and weight of all 1000 students
• outputs the average (mean) height and weight
• includes any necessary error traps for the input of height and weight
Question 4. The weather conditions in a town are being monitored over a year (365 days).
The values recorded per day are weather type and temperature (e.g. CLOUDY, 25)
Write an algorithm, using pseudocode or flowchart only, which:
• inputs the weather type and temperature for each day
• outputs the number of days that were CLOUDY, RAINING, SUNNY or FOGGY
• outputs the highest recorded temperature for the year
• outputs the lowest recorded temperature for the year
Question 5. A small shop uses barcodes which represent 5 digits. The last digit is used as a
check digit.
For example: a b c d e
0 1 2 3 4
The check digit (e) is found by:
• multiplying the first and third digits (i.e. a and c) by 3
• multiplying the second and fourth digits (i.e. b and d) by 2
• adding these four results together to give a total
• dividing this total by 10
• remainder is check digit (e)
Write an algorithm, using pseudocode or flowchart only, which
• inputs 100 five-digit barcodes in the form a, b, c, d, e
• re-calculates the check digit for each number and checks whether the input check digit
• (e) is correct
• outputs the number of barcodes which were entered correctly

Partial preview of the text

Download pseudocode pracitce questions and more Exercises Computer science in PDF only on Docsity!

Question 1 Question 2 : Write an algorithm, using pseudocode or a program flowchart only, which:

  • inputs the population and land area for 500 countries,
  • calculates the population density (i.e. population/land area) for every country,
  • outputs the largest and smallest population density,
  • outputs the average population for all 500 countries. Question 3: A school is doing a check on the heights and weights of all its students. The school has1000 students. Write an algorithm, using pseudocode which,
  • inputs the height and weight of all 1000 students
  • outputs the average (mean) height and weight
  • includes any necessary error traps for the input of height and weight Question 4. The weather conditions in a town are being monitored over a year (365 days). The values recorded per day are weather type and temperature (e.g. CLOUDY, 25) Write an algorithm, using pseudocode or flowchart only, which:
  • inputs the weather type and temperature for each day
  • outputs the number of days that were CLOUDY, RAINING, SUNNY or FOGGY
  • outputs the highest recorded temperature for the year
  • outputs the lowest recorded temperature for the year Question 5. A small shop uses barcodes which represent 5 digits. The last digit is used as a check digit. For example: a b c d e 0 1 2 3 4 The check digit (e) is found by:
  • multiplying the first and third digits (i.e. a and c) by 3
  • multiplying the second and fourth digits (i.e. b and d) by 2
  • adding these four results together to give a total
  • dividing this total by 10
  • remainder is check digit (e) Write an algorithm, using pseudocode or flowchart only, which
  • inputs 100 five-digit barcodes in the form a, b, c, d, e
  • re-calculates the check digit for each number and checks whether the input check digit
  • (e) is correct
  • outputs the number of barcodes which were entered correctly