title: Main.cpp and a Function for Random number Generator C++
body: <p>Hi I'm a newbie up here and my hope to get it right rest here.
  Last semester we dealt with Random number generator me and my friend we were able to come up with a simple program (below) which worked: </p>
  
  <pre><code>using namespace std;
  
  int randomG() {
      int GER(0);
      GER=rand();
      GER %= 10;
      GER++;
      return(GER); 
  }
  
  int main() {
      srand((unsigned)time(NULL));
      for(int i = 0; i != 100; i++) {
          cout &lt;&lt; randomG(); 
      }
  }
  </code></pre>
  
  <p>Now this semester we got given this without going much into it. Basically he want us to To implement the random number generator with main.cpp that call a function FNC multiple times, to test the program we need to use state=1 as initial value. Call FNC from the main program. After 10000 calls: state should be equal to 399268537 (don't get what he mean here)</p>
  
  <p>Below is our starting point:</p>
  
  <pre><code>double rand (void) {
      const long a=48271            //multiplier
      const long b=2147483647      //modulus
      const long c=b/a             //questient
      const long r=b % a           //remainder
      static long state =1;
      long t = a* (state % c) - r * (state/c);
      if(t &gt;0)
          state=t;
      else
          state = t+b;
      return ((double) state / b);
  }
  </code></pre>
  
  <p>for main.cpp we completely lost on what to do, we have no idea on how we going to call the function 
  and coming up with a table from the program output for first 1 to 10 calls and  for 9991 to 10000 calls of FNG. we can't move any further. For sophomore like us, this is total confusion. any help will be apprecaited</p>
  
  <pre><code>int main() {
      srand((unsigned)time(NULL));
      int                        // we lost on what we should put in our main
  </code></pre>
  
  <p>After help from you guys Below is my codes but it still not compiling what am I missing here?</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  double seed(long state) {
      g_state = state;
  }
  
  double rand(void) {
      const long a = 48271;
      const long b = 2147483647;
      const long c = b / a;
      const long r = b % a;
      long t = a* (g_state % c) - r * (g_state / c);
      if (t &gt; 0)
          g_state = t;
      else
          g_state = t + b;
      return ((double)g_state / b);
  }
  
  
  int main() {
      std::vector&lt;double&gt; results;
      for (int i = 1; i &lt;= 10000; ++i) {
          double number = rand(); 
      if (i &lt;= 10 || i &gt;= 9991)
          results.push_back(number);
  }
  </code></pre>