Results 1 to 2 of 2
  1. #1
    ts96 is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default basic while loops

    Im trying to write out the code for these while loops, can you show me how to do these.

    1) “while counter is less than 50, then increase it by one”

    2) “while x is less than y and is not zero, divide x in half”

    attempt at solution:

    1) while (counter<50)
    {
    counter++;
    }

    2) while (x<y && x!=0)
    {
    x=x/2;
    }

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    So far, so good.

    What happened when you tried that inside your code? Or is this just another quiz?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. Basic loops
    By Samari413 in forum New To Java
    Replies: 13
    Last Post: 11-14-2010, 02:19 AM
  2. While Loops, need a bit of help.
    By Keno777 in forum New To Java
    Replies: 7
    Last Post: 10-30-2009, 09:24 PM
  3. these loops...
    By Blaedel in forum New To Java
    Replies: 0
    Last Post: 10-01-2009, 07:59 PM
  4. how to use do while loops
    By mikeitalydz in forum New To Java
    Replies: 32
    Last Post: 09-26-2009, 09:30 PM
  5. Loops (while do etc)
    By manupr in forum New To Java
    Replies: 1
    Last Post: 01-15-2008, 04:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •