For loop adding to a variable

I am trying to create a loop that adds 1 to a int variable every time the if statement is true

But while testing the code even though the if statement is true the variable is not incremented, as if the my for loop is not incremented at all....

Code sample:

int left_jab_count;
    if(area >=100000 && area1 <100000)
        cout<<"LEFT JAB HAS BEEN THROWN"" "<<area<<endl;
        for(int left_jab_count = 0; left_jab_count < 0 ;++left_jab_count)
            cout<<"Left Jab :"<<left_jab_count<<endl;

can anybody see where am going wrong here ?
The loop condition is never true so the loop will never run.
well, I can see that the left_jab_count < 0 makes your for loop not work at all because when you initialize left_jab_count to 0 to begin with, you are saying 0 < 0, which is false making it not work.
OK thx for your replays guys......But what should i do to make it work in this case.
The newly initialised left_jab_count variable in the for block overshadows the mors global one. So your loop doesn't work since 0 is not < 0

Maybe change the 0 in the loop condition to the number of times you want the loop to run.
Well I dont know how many times the loop should run I want it to be dynamic.......meaning that the if stetment might be meet on many occasions there fore I need left_jab_count variable to increment by one every time the condition is meet....And if i set the 0 in my loop condition to lets say 10 and if there is 11th or 12th occurrence nothing will happen...
If all we want to do is increment left_jab_count when the if statement returns true, why is the loop necessary at all? It doesn't appear to actually do anything. Why not just increment, and be done with it?
Topic archived. No new replies allowed.