do while loop

Hey people, Just need soem help with looping my code. I have a dice which rolls a random number and then the player moves how ever many numbers the dice rolled. I have put 24 if else statements in. However I am unsure how to get the code to repeat itself 20 times as I have nothing to keep track of how many times it has run which means i cant implement a do while statement.

Any help most appreciated

thanks guys
What do you need 24 if-else statements for?

Just make a variable that counts. If you must use do-while, then

1
2
3
4
int counter = 0;
do {
   // stuff
} while( ++counter < 21 );
first, without seeing code it's tough to provide any specific help.

Second, 24 if/else statements seems a bit excessive.

Third, just use a counter variable to keep track of how many times you've run.

1
2
3
4
5
int counter = 0;
do{
    counter++;
    //Massive if/else series here
}while(counter<=20);
Topic archived. No new replies allowed.