While Loop


by Krish Beachoo on Aug 9, 2021

Image: https://unsplash.com/@belart84
Edu Level: CSEC,NCSE


While Loop – Unbounded iterations (Unknown number of inputs) The while loop requires a terminating value to determine when to STOP. Usually the condition statement checks for the terminating value. The while construct consists of: While DO End while

Problem 1: Write Pseudocode and draw a flowchart to accept scores terminated by 999 from the user, find and print the total of all the scores.

image

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27547%27%20height=%27510%27/%3e)image

Problem 2: After problem 1 to find the average of all scores entered by the user.

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27608%27%20height=%27340%27/%3e)image

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27241%27%20height=%27565%27/%3e)image

Problem 3: Write Pseudocode and draw a flowchart that reads a series of numbers, terminated by 999 and prints the square of each numbers

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27562%27%20height=%27370%27/%3e)image

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27322%27%20height=%27421%27/%3e)image

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27280%27%20height=%27178%27/%3e)image

Problem 4: Write Pseudocode and draw a flowchart that prompts the user to enter the word 'Quit'. Every time the user enters a name, the the computer should out a greeting for them e.g. if the user enters 'Mary', the computer should output "Hello Mary"

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27534%27%20height=%27323%27/%3e)image

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27284%27%20height=%27470%27/%3e)image

Spot an error? Fill out this form to inform us!