When to use a while loop?
If you are unsure how many times the loop must execute and also if you are unsure if the loop should repeat at all.
For example: The user enters a password. If the password is not 8 characters long you need to add stars (*) until it is 8 characters long. The user might enter a password that is more than 8 characters and then you do not need to add any stars.
ITC
The SAME variable
If you fail to do one of these steps your loop will either not execute at all or fall into an infinite loop.
In the example below sPassword is the variable that needs to be initialised before the loop, tested in the while condition and changed inside the loop.
When to use a Repeat loop?
If you are unsure how many times the loop must execute but the loop must execute at least once.
For example: Repeatedly ask the user to enter the answer to a multiple choice question, until they enter an answer from A - D. The user must enter an answer at least once.
CT
The SAME variable
Failing to do so, will let you fall into an infinite loop. In the example below cAns is the variable that needs to be changed and tested
Practice from past final papers: