title: Program not looping
body: <p>I am trying to write a coin toss program that loops. However my while loop doesn't work. The program should continue until the user presses something other than 'y', but for some reason after the second pass it ends the program.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  
  char coinToss();
  int main() {
  
      char result;
      char ch = 'y';
  
  
      srand(time(0));
  
      while (ch == 'y' || ch == 'Y') {
  
          result = coinToss();
          printf(&quot;The coin toss is %c&quot;, result);
          printf(&quot;\nToss the coin again?&quot;);
          scanf_s(&quot;%c&quot;, &amp;ch, 1);
  
  
      }
  
  }
  
  char coinToss() {
  
      char result;
      int coin;
      coin = rand() % 2 + 1;
      if (coin == 1) {
  
          result = 'T';
      }
      else {
  
          result = 'H';
  
      }
  
      return result;
  }
  </code></pre>