Sure, it could go in the first bracket, but you'd be redeclaring a few variables there too. As I mentioned earlier, it wouldn't do a great deal of harm, but it's better practice to not redeclare.
If you want to deal with the counter later, that's fine and it's probably not as hard as you think. I can help you with that, no problem. But let's take things a step at a time and get the loop sorted first.
I find it helpful to write a functionality list, detail what I want my program to do. It helps me order things, gives context and makes it easier to code. Here's what I'd do in your instance:
1 2 3 4 5 6 7 8 9 10
|
// Declare variables for input, loop condition and wheel position
// Set the loop condition variable
// Seed the random number from time
// -- Start a loop (up to you which kind, personal preference, really)
// -- Ask the user to spin the wheel (essentially, press any key then enter in your case)
// -- Generate a random number
// -- Execute switch statement (which currently will output cout statements)
// -- If it's a while loop, change the condition (important!!)
// -- Exit loop
// Output some kind of end message
|
The 'change the condition' step is important, unless you're using a for loop (where the condition is changed in the actual loop call at the top) or you're altering the condition when calling the while loop (see my second example of a while loop above). If you're using a regular while, like my first while example, and you don't add a (suitable) change to the condition, you're going to find yourself stuck in an infinite loop.
So in the functionality list there, your loop condition variable dictating how many times you want the loop to run:
And that would be used for counting in your loop:
1 2 3 4 5
|
while (iterations) // Note: This is the same as saying while iterations != 0
{
// Do stuff
iterations--;
}
|