arrays

Pages: 12
I may have misunderstood something here. I assumed the value being prompted for at line 12 was the point to make (as in craps). If that number is the total number of rolls to make, then the condition in the do/while loop is wrong. (The prompt was ambiguous).

If the value entered is the maximum number of rolls, then the loop should look like this:
11
12
13
14
15
16
17
  int max_rolls;
  cout <<"Please enter the maximum number of rolls: " ;
  cin >> max_rolls;
  do{ dice = diceRoll();
  myArray[dice]++;  // increment count
  diceThrows++;      // Total rolls
  } while (diceThrows != max_rolls);


Edit: This is exactly why it is important to name your variables appropriately.


Last edited on
Topic archived. No new replies allowed.
Pages: 12