Please help me with a simple algorithm using a while loop

Discussion in 'Java' started by jb82, May 6, 2007.

  1. jb82

    jb82 New Member

    Joined:
    May 6, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    set the initial value of count to 10
    while (NOT (count is 0) )
    write the value of count in the output window
    decrease count by 1
    move to the next line of the output window
    write 'zero' in the output window

    (a) what will be written to the output window when this algorithm is run?
    (b) Suppose the second line of the algorithm were changed to read
    while (count is 11)
    What will be written when the modified algorithm is run?

    How do I get the answers?
    Many thanks jb82
     
  2. abhishekshahi

    abhishekshahi New Member

    Joined:
    Jun 5, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    New Delhi,India
    Hi,

    1)

    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    Zero

    2)

    11
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    Zero

    Do i have answered your question ?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice