title: Random Boolean Value
body: <p>I'm trying to generate a random int that is either 0 or 1 in C++. Right now, I receive a 0 every time I run this code, and I'm not sure why. What's the problem here?</p>
  
  <pre><code>#include &lt;ctime&gt;
  #include &lt;cstdlib&gt;
  
  srand(time(0));
  int randomval = rand() % 2;
  cout &lt;&lt; randomval &lt;&lt; endl;
  </code></pre>