Question Source: KNEC KCSE 1998 Computer Studies
The ‘while…do’ loop is a control structure designed to execute the same block of code again and again until a certain condition is fulfilled.
This loop is used if a condition has to be met before the statements within the loop are executed.
Pseudo code format
WHILE condition DO
Application areas of the ‘while…do’ loop
Most modern programming languages support do…while loop instead of while…do loop, the main difference between the two is; in the former, the statement comes before the condition and in the latter, the condition comes before the statement.
But while…do can be used in Pascal programming language to manipulate repetitive numeric data.
a := 5;
while a < 10 do
writeln('value of a: ', a);
a := a + 1;
value of a: 5
value of a: 6
value of a: 7
value of a: 8
value of a: 9
Follow AtikaSchool.Org on our Social Channels
This gives you an opportunity to get our latest uodates, changes and firsthand information
Don't give up, Keep Searching for more
Click to set custom HTML