for loop

This is a discussion on for loop within the C++ Programming forums, part of the General Programming Boards category; I want to do a loop that iterates the numbers: 1,4,7,10 but when doing this loop, this loop iterates 1,3,3,3,3,3.. ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    59

    for loop

    I want to do a loop that iterates the numbers: 1,4,7,10
    but when doing this loop, this loop iterates 1,3,3,3,3,3.. and keeps showing 3 in infinity.
    Should the loop be done in any other way. Thanks...

    Code:
    for( int i = 1; i < 11; i=+3 )
    {			
    	MessageBox::Show(Convert::ToString(i));
    
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    i=+3
    is probably not quite what you wanted.
    Try
    Code:
    i+=3
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    59
    Stupid of me |..| ofcourse. Now it works. Thank you..

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21