title: Pascal's triangle in C with combinations
body: <pre><code>#include &lt;stdio.h&gt;
  long factorial(int num)
  {
      int counter;
      int fact = 1;
      for (counter = num; counter &gt; 0; counter--) fact *= counter;
      return fact;
  }
  
  float combinations(int n, int k)
  {
      int numerator = factorial(n);
      int denominator = factorial(k) * factorial(n-k);
      float fraction = numerator/denominator;
      return fraction;
  }
  int main()
  {
      printf("How many rows of Pascal\'s triangle should I print?\t");
      int rows = GetInteger();
      int counter;
      int counter2;
      for (counter = 1; counter &lt;= rows; counter++)
      {
          int y = rows-counter;
          for (; y &gt; 0; y--) printf("   ");
          for (counter2 = 0; counter2 &lt;= counter; counter2++)
                  printf("%6.0lu", (long) combinations(counter, counter2));
          printf("\n");
      }
  }
  </code></pre>
  
  <p>Every time I go past twelve rows, the numbers start to decrease. What am i doing wrong?</p>
  
  <p>And, <code>GetInteger()</code> is just a <code>scanf()</code> with a few touch ups. I am 100% sure it works perfectly.</p>