title: Roulette random number and if statement c++
body: <p>I am making a roulette table and wanted to ask a question, but also have help with fixing code.</p>
  
  <p>1, currently I am using rand()%37 as my random number generator for the 0-36 numbers. Is there a better generator that gives a more random number? </p>
  
  <p>2, I am unsure how to check values in an array against an if statement. (check code below)</p>
  
  <pre><code>int red[18] = {1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36};
  
  int main ()
  {
  
  srand(time(NULL));
  r = rand() % 3;
  cout &lt;&lt; r &lt;&lt; endl;
  for(int i = 0; i&lt;18; i++)
      if (r==red[i])
      {
          cout &lt;&lt; "hello" &lt;&lt; endl;
          break;
      }
      else 
      {
          cout &lt;&lt; "bye" &lt;&lt; endl;
          break;
      }
  return 0;
  }
  </code></pre>
  
  <p>When i run this code, it returns bye even if r (random number) is in the array red. </p>
  
  <p>To woolstar: this is a simplfied version of my actual code. I want to have a random number be generated (r) and then check this number against the array red, if r is in the array I want it to be considered true and print hello in this case</p>
  
  <p>E.g. r = 14, is 14 in array red? Yes: print hello</p>
  
  <p>Edit: Here is my actual code, when running the random number and find in case B and C it comes back with errors saying: initialization are skipping case labels</p>
  
  <pre><code>// Random number generator
  random_device rd;
  mt19937 gen (rd());
  
  uniform_int_distribution&lt;&gt;
  dis  (0, 36);
  
  switch (play_method)
      {
          case 1:                                     // Color Play
          cout &lt;&lt; "A - Play Red.\n";
          cout &lt;&lt; "B - Play Black.\n";
          cout &lt;&lt; "C - Play Green.\n";
          cout &lt;&lt; "Which color will you bet on?" &lt;&lt; endl;
          cin &gt;&gt; color;
  
          switch (color)
          {
              case 'A':                               // Red Play
                      int rred = dis(gen);
                      auto
  
                  it = find(begin(red),end(red), rred);
                      if(it!=end(red))
                      {
                          win_amt = bet_amt*2;
                          total_amt = total_amt + (win_amt - bet_amt);
                          cout &lt;&lt; "Congratulations you rolled a " &lt;&lt; r &lt;&lt; " and have won: $" &lt;&lt; win_amt &lt;&lt; "!" &lt;&lt; endl;
                          cout &lt;&lt; "You now have: $" &lt;&lt; total_amt &lt;&lt; " remaining." &lt;&lt; endl;
                      }
                      else
                      {
                          total_amt = total_amt - bet_amt;
                          cout &lt;&lt; "Unlucky, you rolled a " &lt;&lt; r &lt;&lt; " and have have lost  $" &lt;&lt; bet_amt &lt;&lt; endl;
                          cout &lt;&lt; "You have $ " &lt;&lt; total_amt &lt;&lt; " remaining." &lt;&lt; endl;
                      }           // Red play if/else end                 
              break;                                  // Break for case A: Red play
  
               case 'B':                              // Black play
                      int rblack = dis(gen);
                      auto
  
                  it1 = find(begin(black),end(black), rblack);
                      if(it1!=end(black))
                      {
                          win_amt = bet_amt*2;
                          total_amt = total_amt + (win_amt - bet_amt);
                          cout &lt;&lt; "Congratulations you rolled a " &lt;&lt; r &lt;&lt; " and have won: $" &lt;&lt; win_amt &lt;&lt; "!" &lt;&lt; endl;
                          cout &lt;&lt; "You now have: $" &lt;&lt; total_amt &lt;&lt; " remaining." &lt;&lt; endl;
                      }
                      else
                      {
                          total_amt = total_amt - bet_amt;
                          cout &lt;&lt; "Unlucky, you rolled a " &lt;&lt; r &lt;&lt; " and have have lost  $" &lt;&lt; bet_amt &lt;&lt; endl;
                          cout &lt;&lt; "You have $ " &lt;&lt; total_amt &lt;&lt; " remaining." &lt;&lt; endl;
                      }                   // Black play if/else end 
  
              break;                      // Break for case B: Black play 
  
              case 'C':
                  int rgreen = dis(gen);
                      auto
  
                  it2 = find(begin(green),end(green), rgreen);
                      if(it1!=end(green))
                      {
                          win_amt = bet_amt*37;
                          total_amt = total_amt + (win_amt - bet_amt);
                          cout &lt;&lt; "Congratulations you rolled a " &lt;&lt; r &lt;&lt; " and have won: $" &lt;&lt; win_amt &lt;&lt; "!" &lt;&lt; endl;
                          cout &lt;&lt; "You now have: $" &lt;&lt; total_amt &lt;&lt; " remaining." &lt;&lt; endl;
                      }
                      else
                      {
                          total_amt = total_amt - bet_amt;
                          cout &lt;&lt; "Unlucky, you rolled a " &lt;&lt; r &lt;&lt; " and have have lost  $" &lt;&lt; bet_amt &lt;&lt; endl;
                          cout &lt;&lt; "You have $ " &lt;&lt; total_amt &lt;&lt; " remaining." &lt;&lt; endl;
                      }                   // Green play if/else end */
              break;
  
          }                               // Switch color end
          break;                          // break for case 1: Color play
  </code></pre>