title: C++ Writing simple coin flip game
body: <p>I'm writing a code for a game that prompts the user to pick how many times they want to flip a coin and guess how many times it will land on heads. I wrote most of, just need help finishing it up. I tried to include a count of the heads but ran into problems. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  int myRandNumGen(){
  
      int num = rand();
  
      return num;
  }
  char coinTossFunction( ){
  
  
      char coinToss;
      int coinTossValue = (myRandNumGen()%2); // 0 or 1
  
      switch (coinTossValue) {
          case 0:
  
              coinToss = 'H';
  
              break;
  
          case 1:
  
              coinToss = 'T';
  
              break;
  
          default:
  
              break;
          }
      return coinToss;
  }
  
  int calcCoin(int n){
  
      int cout_heads=0;
  
      for(int i=0;i&lt;=n;i++){
  
          if(coinTossFunction() == 'H')
  
              ++cout_heads;
  
      }
  
      return (cout_heads/n);
  
  }
  
  
  
  
  int main(){
  
      int coinflips, guess;
  
      cout &lt;&lt; "How many times do you want to flip the coin? " &lt;&lt; endl;
      cin &gt;&gt; coinflips;
  
      cout &lt;&lt; "Guess how many times a coin will land on heads if flipped: " &lt;&lt; endl;
      cin &gt;&gt; guess;
      if (guess&gt;coinflips) {
          cout &lt;&lt; "Guess Error";
  
      }
  
  
      for(int i=1;i&lt;=coinflips;i++){
          cout &lt;&lt; calcCoin;
  
  
      }
  </code></pre>