title: Strange Errors. Using rand() and arrays within a loop
body: <p>I really can not explain what is going on with my program. I really can't spot what may be causing the problems. It occurs within this function</p>
  
  <pre><code>void test()
  {
      srand(time(NULL));
  
      questionNo = 1;
  
      for (testLoop = 0; testLoop &lt; 10; ++testLoop)
      {
          const char opArray[3] = { 'x', '+', '-' };
          int pickValue = rand() % 3;
          char Operator = opArray[pickValue];
  
          int n1 = rand() % 20 + 1;
          int n2 = rand() % 20 + 1;
  
          if (Operator = '+')
              answer = n1 + n2;
          else if (Operator = '-')
              answer = n1 - n2;
          else
              answer = n1 * n2;
  
          cout &lt;&lt; "Question " &lt;&lt; questionNo &lt;&lt; "\n";
          ++questionNo;
          cout &lt;&lt; n1 + " " &lt;&lt; Operator + " " &lt;&lt; n2 &lt;&lt; "?";
          userAnswer = cin.get();
  
          if (userAnswer = answer)
          {
              cout &lt;&lt; "\n\n Correct!\n";
              system("cls");
              ++score;
          }
          else
          {
          cout &lt;&lt; "\n\n Incorrect!\n";
          system("cls");
          }
          Sleep(500);
      }
      cout &lt;&lt; "You scored " &lt;&lt; score &lt;&lt; " out of 10!";
      fileWrite(score);
  }
  </code></pre>
  
  <p>An example of what occurs is the following.
  This outputs to console </p>
  
  <p>Question 1<br>
  @Øÿ×╝×³×0ƒ11?  </p>
  
  <p>What even is that???<br>
  It also skips two questions every time. For example it goes</p>
  
  <p>"Question 1"<br>
  "Question 3"<br>
  "Question 5"  </p>