title: Displaying content with a for loop
body: <p>I'm trying to write a program that randomly selects three items from an array that contains five different fruits or vegetables and then display this randomly selected content to the user. Now I'm having trouble understanding why my output is not consistent because sometimes when I run it I'll get something like this: </p>
  
  <pre><code>This bundle contains the following: 
  
  
  Broccoli
  </code></pre>
  
  <p>With the first two items missing and sometimes I'll get this: </p>
  
  <pre><code>This bundle contains the following: 
  Tomato
  Tomato
  Tomato
  </code></pre>
  
  <p>This is the portion of the code I'm currently having trouble with:</p>
  
  <pre><code>void BoxOfProduce::output() {
  
          cout &lt;&lt; "This bundle contains the following: " &lt;&lt; endl;
  
          // Use this so it will be truly random
          srand(time(0));
  
          for (int f = 0; f &lt; 3; f++) {
  
              // Here were making the random number
              int boxee = rand() % 5;
  
              // Adding the content to the box
              Box[f] = Box[boxee];
  
              // Now were calling on the function to display the content
              displayWord(boxee);
  
          } // End of for loop
  
      } // End of output()
  
  
      void BoxOfProduce::displayWord(int boxee) {
  
          cout &lt;&lt; Box[boxee] &lt;&lt; endl;
  
      }
  
  
  int main() {
  
      BoxOfProduce b1;
      b1.input();
      b1.output();
  </code></pre>
  
  <p>Can someone help me understand why i'm getting this output? Thanks!</p>