Re: Reverse Loop?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Duniho

    Re: Reverse Loop?

    On Sat, 17 May 2008 16:36:17 -0700, <msnews.microso ft.comwrote:
    [...]
    I can't seem to get the for (int i = 80; i <= 50; i++) loop working out
    properly. Any advice would be great. Thank you.
    Sounds like a homework problem.

    Here's a hint: if you want your loop to go backwards, adding to
    (incrementing) the counter isn't going to work.

    Here's another hint: if you want fractional values, using integers isn't
    going to work.

    One final hint: in a "for()" statement, the three parts have very broad
    rules for usage. The first part is executed once, before the loop begins,
    and may contain variable declarations; the second part must simply be some
    sort of logical expression that evaluates to a boolean...it can be _any_
    expression that meets that requirement; and finally, the third part can be
    any statement or statements (separated by commas)...there 's nothing that
    says it can only be a variable combined with a post-increment operator.

    With that information, I think you should be able to rewrite your loop so
    that it meets your need.

    Pete
  • Rain

    #2
    Re: Reverse Loop?

    Love the hints, espectially this one *******. Thats really made my day......

    ;-D



    "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
    news:op.ubbokww a8jd0ej@petes-computer.local. ..
    On Sat, 17 May 2008 16:36:17 -0700, <msnews.microso ft.comwrote:
    [...]
    I can't seem to get the for (int i = 80; i <= 50; i++) loop working out
    properly. Any advice would be great. Thank you.
    Sounds like a homework problem.

    ***** Here's a hint: if you want your loop to go backwards, adding to
    ******
    (incrementing) the counter isn't going to work.

    Here's another hint: if you want fractional values, using integers isn't
    going to work.

    One final hint: in a "for()" statement, the three parts have very broad
    rules for usage. The first part is executed once, before the loop begins,
    and may contain variable declarations; the second part must simply be some
    sort of logical expression that evaluates to a boolean...it can be _any_
    expression that meets that requirement; and finally, the third part can be
    any statement or statements (separated by commas)...there 's nothing that
    says it can only be a variable combined with a post-increment operator.

    With that information, I think you should be able to rewrite your loop so
    that it meets your need.

    Pete


    Comment

    Working...