Thread: Simple loop question

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

  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, 12:34 PM
  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, 09: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, 01:08 PM