title: How do I create a 2d array in C++ that contains the counter of the loop in one part and a list of numbers in the other part?
body: <p>I am trying to count the number of occurrences of a randomly generated number in 3 different cases: 10, 1,000, and 100,000 iterations. In each iteration, I would like to count the number of occurrences of numbers 1 to 6 and then later on compare these counts.</p>
  
  <p>This is my idea of implementation: Have a nested <code>for</code> loop where the outer one will iterate from case 1 to case 3 and the inner <code>for</code> loop will generate a random number for each case, count the frequency of occurrence and put that into an array.</p>
  
  <p>When I exit the inner <code>fo</code>r loop, I would like to take that array and put it inside another array which is 2d so it saves the values for each case.</p>
  
  <p>Here's my C++ code for that so far:</p>
  
  <pre><code>extern "C"{
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  }
  #include &lt;iostream&gt;
  using namespace std;
  
  int genRand(){
      int min = 1;
      int max = 6;
      int randNum = min + rand() / (RAND_MAX / (max - min + 1) + 1);
      return randNum;
  }
  
  int main(){
  
  //Seeds the random number generator(takes the current time and uses it to randomize)
  srand((unsigned int)time(NULL));
  
  //Part 1 - Roll a single die 10, 1000, and 100 000 times
  
  //First part holds the number of cases and the second hold the number of occurances
  int randArr[3][6] = {0};
  int countArr[6] = {0};
  
  int mult = 1; int randNum = 0;
  for(int i = 0; i&lt;3; i++){
      for(int j = 0; j&lt;10*mult; j++){
          randNum = genRand();
          for(int k = 1; k&lt;=6; k++){
              if(randNum == k) { countArr[k-1]++;}
          }
      }
      mult *= 100;
      randArr[i][i] = i, countArr[i];
      }
  }
  </code></pre>
  
  <p>I believe my last line is wrong but I don't understand why or how to make a 2d array such that the first part is the case number(which in this case would be i) and then the second input would be the array I created earlier with the frequency of occurrences.</p>
  
  <p>Could someone help point out what I'm doing wrong?</p>