CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: Paul McKenzie

Search: Search took 3.15 seconds.

  1. Replies
    68
    Views
    58,827

    Re: Fun C++ Problem

    -20 + 20 = 0.

    Take a look at the for loop, and the terminating condition. Since on the 20th iteration:
    i + n =
    -20 + 20 =
    0 =
    false

    The loop terminates.
  2. Replies
    68
    Views
    58,827

    Re: Fun C++ Problem

    Negating a negative gives you a positive.


    int i, n = 20;
    for (i=0;-i<n; i--)
    {
    cout << "x" << endl;
    }

    Regards,
  3. Replies
    68
    Views
    58,827

    Re: Fun C++ Problem

    A hint to the third solution, if it's the one I think some here are having a problem with, is "do the math".

    Regards,

    Paul McKenzie
  4. Replies
    68
    Views
    58,827

    Re: Fun C++ Problem

    I have all three.

    Regards,

    Paul McKenzie
Results 1 to 4 of 4





Click Here to Expand Forum to Full Width

Featured