title: Simple C++ factorial program
body: <p>as homework I need a program that reads a nonnegative integer and computes and prints its factorial.
  So far I wrote the code but if I try to input 50! the result is 0. It works with smaller numbers. Any help would be much appreciated.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      int counter = 1;
      int number;
  
      cout &lt;&lt; "Please enter a number: ";
      cin &gt;&gt; number;
  
      int factorial = number;
      while (counter != number)
      {
          factorial = factorial * (number - counter);
          counter++;
  
      }
  
      cout &lt;&lt; "The factorial of " &lt;&lt; number &lt;&lt; "! is: " &lt;&lt; factorial &lt;&lt; endl;
      return 0;
  }
  </code></pre>