title: C++ Random number generator from a specific array
body: <p>I want to be able to generate random numbers from a specific array that I will place. For example: I want to generate a random number from the array {2,6,4,8,5}. its just that there is no pattern in the array that I want to generate. </p>
  
  <p>I was only able to search how to generate a random number from 1-100 using srand() from the video tutorial <a href="https://www.youtube.com/watch?v=P7kCXepUbZ0&amp;list=PL9156F5253BE624A5&amp;index=16" rel="nofollow">https://www.youtube.com/watch?v=P7kCXepUbZ0&amp;list=PL9156F5253BE624A5&amp;index=16</a> but I don't know how to specify the array that it will search from..</p>
  
  <p>btw, my code is similar to this..</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  
  int main(int argc, char*argv[])
  {
      srand(time(0)); 
  
      int i =rand()%100+1;
      cout &lt;&lt; i &lt;&lt; endl; 
      return 0;
  }
  </code></pre>