• Status: Solved
• Priority: Medium
• Security: Public
• Views: 341

# increas value in for loop

Hello,

is it possible to increase a value with more than 1 inside a for loop?

like
for(int i = 0; i<nCount;i+300){

}
?
Ingo
0
Ocrana
1 Solution

Commented:
Yes, just fix the last expression to do an assignment.

i.e.

``````for(int i = 0; i<nCount; i = i+300){
...
``````
0

Commented:
Or
0

Software EngineerCommented:
yes, it's possible. In your code, you r doing i+300, which doesn't have any impact upon the execution of for().
If you want value of i should be incremented in steps of 300, then you should say something
like i+=300 or i = i + 300, as already mentioned by other experts.

Really i' m not understanding why this thing came into your mind. I hope you found that your code isn't behaving as per your wish. This is because, by saying i+300, value of i is not incrementing. To do that you have to assign it to variable i as said above.
0

Commented:
even better there can be ....

``````...
for(i=0; i<nCount; i+=300){
...
i += 250;
}
...
``````
0

Commented:
@sinisav

That approach was mentioned above  : )
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

Tackle projects and never again get stuck behind a technical roadblock.