Thread: Looping condition

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    153

    Looping condition

    Hey everyone,
    I'm currently reading a book on program design, and the author mentions (keep in mind this is all in pseudocode, nothing about C++ at all) a loop called REPEAT...UNTIL which executes the body prior to testing the condition, exactly like the do...while, the thing is though, the author says that the repeat until loop iterates as long as the condition is false, once it becomes true it ends. I thought this sounded a little ridiculous and decided to come on the forums to see if anybody knew if there was anything like this in C++ or C or something like that. As far as I know the only way to do this would be !(condition)...I was just wondering what the author was talking about in terms of specific loop syntax.

    On a slightly related note, does anyone know of any good program design books? Something more procedural because that's where my weakness is...otherwise thanks for hearing me out. -Chap

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > repeat until loop iterates as long as the condition is false
    C and C++ do not have repeat until, they have do while (which achieve the same thing)
    So your pseudo code repeat until cond is the same as do while !cond

    > I was just wondering what the author was talking about in terms of specific loop syntax.
    Probably just trying to get across the differences between loops which test a condition at the start, and those which test a condition at the end. Mapping the concept to actual language constructs is left to the reader.

    > On a slightly related note, does anyone know of any good program design books?
    http://www.accu.org/bookreviews/public/index.htm
    Not really a short list, but might be useful.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Does the author mean something like this?
    Code:
    do{
        RunProgram();
    } while (Exit == false);

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    what the author meant (probably) is if the condition changes it's value anywhere in the cicle, the cicle breaks, then, not in the end of a cicle like with for, do-while or while.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. condition variable on read/write locks
    By ShwangShwing in forum C Programming
    Replies: 3
    Last Post: 04-29-2009, 09:32 AM
  2. Condition variables
    By sethjackson in forum Windows Programming
    Replies: 16
    Last Post: 03-19-2008, 11:42 AM
  3. looping and condition problems
    By liukinhei in forum C Programming
    Replies: 1
    Last Post: 03-11-2008, 02:40 AM
  4. SDL Condition variables.
    By antex in forum Game Programming
    Replies: 3
    Last Post: 11-11-2005, 07:11 AM
  5. Race condition
    By Roaring_Tiger in forum C Programming
    Replies: 5
    Last Post: 10-24-2004, 09:42 PM