title: Find whether a random number is Prime or not and Store in a character value
body: <p>I am writing a game, where it should do below</p>
  
  <p>Randomly generate a number. Check whether it is a Prime or not. Store "y" if its a Prime else "n"</p>
  
  <p>I will ask the user whether it is prime or not. If he answers correctly I will proceed. Otherwise I will say you lost.</p>
  
  <p>Code sample I tried is as follows:</p>
  
  <pre><code>cout&lt;&lt;"\n \n a no. of prime no.s will be displaed to you ,you will have to decide if it is prime or not within the given time\n \n ";
  char ch1,ch2;
  for(int i=1;i&lt;=20;i++)
  {
      int a= rand( ) % 20;
      cout&lt;&lt; "The number is:";
      cout&lt;&lt;a;
      for(int l=2;l&lt;=a-1;l++)
      {
          if(a%l==0)
              ch2='n';
          else
              ch2='y';                            
      }
  
      cout&lt;&lt;ch2;   
      cout&lt;&lt;"\n\n Enter ""y"" If the number is Prime Else Please enter ""n""\n";                       
      cin&gt;&gt;ch1;
      if(ch1 == ' ')
      {
          cout&lt;&lt;"\n \n u lost";
          break;
      }
      else if(ch1==ch2)
          continue;
      else if(ch1!=ch2)
      {
          cout&lt;&lt;"\n \n u lost";
          break;
      }
  }
  </code></pre>
  
  <p>My code is not determining whether it is Yes or No. It is everytime storing "Y" only</p>