title: Random number for Rock Paper Scissors
body: <p>just a quick question. 
  I'm very new to c++. here I've created a random number generator which should get a random number from 1-3 and then each number corresponds to rock paper or scissors.</p>
  
  <p>The problem is, it picks scissors (3) every time!! What have I done wrong?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  int i, a, b;
  int playerschoice, compchoice;
  
  main()
  {
      compchoice=rand() %3+1;
      printf("compchoice=%d",compchoice);
  
      if (compchoice == 1)
      {
          printf("\nThe computer is going with: Rock...\n");
          b = 0;
      }
      else if (compchoice == 2)
      {
          printf("\nThe computer is going with: Paper...\n");
          b = 1;
      }
      else if (compchoice == 3)
      {
          printf("\nThe computer is going with: Scissors...\n");
          b = 2;
      }
  
      system("pause");
      return 0;
  }
  </code></pre>