title: C program that multiplies numbers from 1 to N
body: <p>I am trying to write a program that multiplies all the numbers from <code>1</code> to <code>N</code> where <code>N</code> is a number that was entered by the user.</p>
  <p><strong>For example if I type in <code>5</code>, I want to the program to multiply every number from <code>1</code> to <code>5</code>.</strong></p>
  <p>The program would calculate <code>1 * 2 * 3 * 4 * 5 = 120</code>.</p>
  <p>I am new to C and programming in general but I managed to write this code that does something similar to what I want.</p>
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(void)
  {
      int N, rem, prod = 1;
  
      printf(&quot;Enter the value of N: &quot;);
      scanf(&quot;%d&quot;, &amp;N);
  
      while(N != 0)
      {
          rem = N % 10;
          prod *= rem;
          N /=  10;
      }
  
      printf(&quot;%d&quot;, prod);
  
      return 0;
  }
  </code></pre>
  <p>My code multiples each number with each other but the user has to enter each one manually.</p>
  <p>For example if I wanted to achieve the output I mentioned before, I would have to type in <code>12345</code>.</p>
  <p><strong>Instead I would like to type just <code>5</code>.</strong></p>
  <p>I would appreciate some guidance on this.</p>