0% found this document useful (0 votes)
30 views1 page

Which LOOP Should I Use

The document discusses three types of loops in programming - while, do-while, and for loops. The while loop repeats until a condition is met, which may be determined by the user. Do-while also repeats based on a condition, but always runs the body at least once. The for loop repeats a specific number of times as determined by the program or user, counting the number of iterations.

Uploaded by

AdAm Jazz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Which LOOP Should I Use

The document discusses three types of loops in programming - while, do-while, and for loops. The while loop repeats until a condition is met, which may be determined by the user. Do-while also repeats based on a condition, but always runs the body at least once. The for loop repeats a specific number of times as determined by the program or user, counting the number of iterations.

Uploaded by

AdAm Jazz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Which LOOP should I use????

while:

the loop must repeat until a certain "condition" is met. If the "condition" is FALSE at the beginning of the loop, the loop is never executed. The "condition" may be determined by the user at the keyboard. The "condition" may be a numeric or an alphanumeric entry. This is a good, solid looping process with applications to numerous situations.

do-while:

operates under the same concept as the while loop except that the dowhile will always execute the body of the loop at least one time. (Do-while is an exit-condition loop -- the condition is checked at the end of the loop.) This looping process is a good choice when you are asking a question, whose answer will determine if the loop is repeated.

for:

the loop is repeated a "specific" number of times, determined by the program or the user. The loop "counts" the number of times the body will be executed. This loop is a good choice when the number of repetitions is known, or can be supplied by the user.

You might also like