Google Answers Logo
View Question
 
Q: Loops Loops ( Answered,   1 Comment )
Question  
Subject: Loops Loops
Category: Computers > Programming
Asked by: mrfony-ga
List Price: $4.00
Posted: 08 Oct 2002 13:54 PDT
Expires: 07 Nov 2002 12:54 PST
Question ID: 74138
Consider the following types of loops

do while ..loop
do ..loop while 
do until..loop
do..loop until

1.Is the test made before or after the range of statements is
executed?
2.What is the minimum number of times the range of  statements is
executed?
3.Does the do loop terminate when the condition is true or false?

I cant seem to find an answers to these questions in my book can you
help me answer the following loops?

Thank You 
Sue
Answer  
Subject: Re: Loops Loops
Answered By: synarchy-ga on 08 Oct 2002 14:08 PDT
 
Hi -

do while ... loop - tests before the range of statements, is executed
a minimum of 0 times and terminates when the condition is false.

do ... loop while - tests at the end of the statements, so is executed
at least once and also terminates when the condition is false.

do until ... loop - tests before the range, is not necessarily
executed and terminates when the condition is true

do ... loop until - tests at the end of the range, is executed once,
and terminates when the condition is true

A good, short, to-the-point explanation of loop constructs:
http://www.cyberiapc.com/master/vblesson5.htm

A nice powerpoint presentation explaining these constructs can be
found here:
http://www.scit.wlv.ac.uk/~cm1810/CP1020/lectures/lecture7.ppt

synarchy
Comments  
Subject: Re: Loops Loops
From: wod-ga on 14 Oct 2002 02:04 PDT
 
Small tip.. with strange loops I find it helpful to look at where the
condition is in the program.. if the condition is on the "top" of the
loop, then it gets tested before the stuff gets done the first time.
Otherwise it gets done after. Right ? :)

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy