Thread: While loop problems

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    27

    While loop problems

    I'm new to programming. What is the difference between a while and do while loop?
    Last edited by noodle24; 02-12-2006 at 10:50 AM.

  2. #2
    Master of Puppets rwmarsh's Avatar
    Join Date
    Feb 2006
    Location
    Texas
    Posts
    96
    the difference is like this....

    Code:
    while {argument}
        {statement}
    the statements will only be performed if the argument is true, then will continue to loop until false


    Code:
    do
        {statement}
    while {argument}
    the statements will be performed at least once, before the argument is tested. Then if the argument is true it will continue to loop until false.

    I hope this helps

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    ...and what rwmarsh said minus the syntax errors:

    Code:
    while (conditional){ 
    }
    
    do {
    } while(conditional);
    His explaination was correct, though.
    Sent from my iPadŽ

  4. #4
    Master of Puppets rwmarsh's Avatar
    Join Date
    Feb 2006
    Location
    Texas
    Posts
    96
    oops... your right Sly Maelstrom...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-01-2008, 10:09 AM
  2. "for" loop problems....
    By hayai32 in forum C Programming
    Replies: 4
    Last Post: 05-04-2005, 01:20 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. simple collision detection problems
    By Mr_Jack in forum Game Programming
    Replies: 0
    Last Post: 03-31-2004, 04:59 PM
  5. problems with greatest to least sorting
    By Mr_Jack in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2004, 10:12 PM