title: I am trying to use an array in an If statement
body: <p>I am trying to use an array in an if statement to determine whether the value of x is rare or not. </p>
  
  <p>If I do it this way everything is common.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  
  int main(){
      int y[5] = {1,2,3,4,5};
      srand(time(0));
  for(int z = 0; z &lt;= 50; z++){
      int x = 1 + (rand()%6);
      cout &lt;&lt; z;
      cout &lt;&lt; " " &lt;&lt;x;
      if(y[5] == x){
          cout &lt;&lt; ": Common" &lt;&lt; endl;
      }else{
          cout &lt;&lt; ": RARE" &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>But if I do it this way everything is rare.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  
  int main(){
      int y[5] = {1,2,3,4,5};
      srand(time(0));
  for(int z = 0; z &lt;= 50; z++){
      int x = 1 + (rand()%6);
      cout &lt;&lt; z;
      cout &lt;&lt; " " &lt;&lt;x;
      if(y[5] == ++x){
          cout &lt;&lt; ": Common" &lt;&lt; endl;
      }else{
          cout &lt;&lt; ": RARE" &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>I am really stumped on what to do can someone please help me?</p>