I have counter increase by one every once (round in loop) when the counter equal 100 am need it to go back and count down from 100 to 0, how i can make counter count down again ?

int i = 0;
           if(i<=100) 
           {i-- ;)  // that false 
           else 
           {i++ ;}

You could use a flag/boolean to remember if you are going up or are going down.

You could set an increment variable. Start it at 1, and flip it to -1 when the counter reaches 100. Then your increment step is simply counter += increment. Be sure to set your loop exit condition to counter >= 0, or you'll keep counting down forever.

Member Avatar for hfx642

Actually... Your answer is a combination of the last two posts.
Remember which direction you are traversing,
AND have lower and upper bounds of travel.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.