Simple loop question

This is a discussion on Simple loop question within the C Programming forums, part of the General Programming Boards category; Code: while ((x-1)) { ++counter; x--; } can someone tell me what the condition is to exit the loop? Is ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    53

    Simple loop question

    Code:
    while ((x-1))
      {
       ++counter;
       x--;
      }
    can someone tell me what the condition is to exit the loop? Is it while x-1 not equal to 0?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,418
    Did you get a chance to test it in the 30 minutes waiting for a reply?

    And yes is the answer.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    53
    Yes i did test it but getting a result and watching watchers doesn't necessarily explain the lines definition...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple for loop question
    By benrogers in forum C Programming
    Replies: 2
    Last Post: 02-28-2011, 11:34 AM
  2. simple loop incrament question
    By aweida in forum C Programming
    Replies: 5
    Last Post: 09-27-2010, 10:40 PM
  3. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 08:23 AM
  4. simple for loop function question
    By felicityxiv in forum C Programming
    Replies: 7
    Last Post: 05-06-2006, 11:43 PM
  5. Please don't laugh...SIMPLE loop question!
    By the_lumin8or in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2006, 12:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21