Thread: for loop

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    12

    for loop

    In a for loop i is incremented by i using i++

    eg. for(i=0;i<10<i++)

    Is there any way to increment by more than one other than:

    eg.

    Code:
    for(i=0;i<10<i++)
    { 
      i += 5;
      .
      .
     }
    I tried playing around with the increment operator (the i++) but I can't get anything else to work.

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Code:
    for(i=0;i<10<i += 5) { 
    }
    Code:
    for(i=0;i<10< i = i + 5) {
    }

    as the ; the third part in the for loop is a condition you can put a C/C++ condition there dude

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    sorry not third part

    first is initialization
    second is condition
    third is decrement or increment or any statement which will change the value of i like i /= 2 and something like that

  4. #4
    Registered User
    Join Date
    Sep 2009
    Posts
    12
    Quote Originally Posted by RockyMarrone View Post
    Code:
    for(i=0;i<10<i += 5) { 
    }
    Code:
    for(i=0;i<10< i = i + 5) {
    }

    as the ; the third part in the for loop is a condition you can put a C/C++ condition there dude
    cheers mate, i had simply put put in i+5 instead of i = i+5

Popular pages Recent additions subscribe to a feed