XML

kent logo

CO631 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for loops

2000

Question 45 (2000):

Example:

  PROC whyowhyOccam(CHAN OF whatever.....)
    BOOL b:
    SEQ
      b:=TRUE
      WHILE b
         ... Code
         IF
           occam = bad
             .. b:=false
           TRUE
             .. More code
  :

With this program, when occam does equal bad :), then b is set to false. Does this mean that the WHILE-loop wiill terminate or does something else happen? When I run it, the WHILE-loop will not terminate when occam equals bad.

Answer 45:

Your code has indentation errors and a missing SEQ ... and I'm not sure what your:

             .. b:=false

means? Might you be doing something in the dots that sets b true again? If your code really is this:

  PROC whyowhyOccam (CHAN OF whatever.....)
    BOOL b:
    ...  declarations of your variables occam and bad
    SEQ
      b := TRUE
      WHILE b
        SEQ
          ...  code that sets occam and/or bad
          IF
            occam = bad
              SEQ
                b := FALSE
                ...  something that doesn't change b
            TRUE
              ...  more code
  :

then if occam equals bad inside the loop, the loop will terminate - promise!

Keywords: loops

Valid CSS!

Valid XHTML 1.0!

Last modified Mon May 15 17:39:46 2006
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.