Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

"do" loop confusion.

loop

  • Please log in to reply
8 replies to this topic

#1 Dalin

Dalin

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 12 October 2008 - 09:31 AM

Is this a good example of a do loop?

do {
     blah
} while (blah something);

For some reason i was always confused with do loops.
  • 1

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 12 October 2008 - 10:34 AM

That's about the simplest do loop there is :)
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 redkid

redkid

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 12 October 2008 - 06:11 PM

Yeah, that looks like it straight out of a book!
  • 0

#4 Dalin

Dalin

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 12 October 2008 - 07:04 PM

Oh, lol i always thought that was the wrong way.
  • 0

#5 Steve.L

Steve.L

    CC Addict

  • Member
  • PipPipPipPipPip
  • 382 posts
  • Location:Kingston, Canada
  • Programming Language:C, Java, C++, PHP, Python, Ruby, PL/SQL, Delphi/Object Pascal, Lisp, Pascal, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 12 October 2008 - 08:54 PM

Yeah, it's like you said:

do {
   statement block
} while(condition);

So you will ALWAYS go through the loop at least once. Kinda useful.
  • 0

#6 dcs

dcs

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 730 posts

Posted 12 October 2008 - 10:09 PM

So you will ALWAYS go through the loop at least once. Kinda useful.

Heh. Kinda reminds me of the do {/*...*/} while(0) thing.
  • 0

#7 Steve.L

Steve.L

    CC Addict

  • Member
  • PipPipPipPipPip
  • 382 posts
  • Location:Kingston, Canada
  • Programming Language:C, Java, C++, PHP, Python, Ruby, PL/SQL, Delphi/Object Pascal, Lisp, Pascal, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 13 October 2008 - 08:25 AM

Heh. Kinda reminds me of the do {/*...*/} while(0) thing.


Well, that's obviously useless, unless you mean to put in a different condition later on.
  • 0

#8 dcs

dcs

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 730 posts

Posted 13 October 2008 - 09:02 AM

Well, that's obviously useless, unless you mean to put in a different condition later on.

You didn't follow the link?
  • 0

#9 Steve.L

Steve.L

    CC Addict

  • Member
  • PipPipPipPipPip
  • 382 posts
  • Location:Kingston, Canada
  • Programming Language:C, Java, C++, PHP, Python, Ruby, PL/SQL, Delphi/Object Pascal, Lisp, Pascal, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 13 October 2008 - 09:06 AM

Oh I see... That's kind of interesting... lol
  • 0





Also tagged with one or more of these keywords: loop

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download