title: printing digits in reverse order using function in c
body: <p>Hi I am pretty new to coding. So I was given this assignment by my teacher as mentioned in the title. This is what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void main() {
      int n;
      printf("Enter n: ");
      scanf("%d", &amp;n);
      printf("%d in reverse order is ", n);
      printf("%d", reverse(n));
  }
  
  int reverse(int n) {
      int r;
  
      do {
          r = n % 10;
          printf("%d", r);
          n = n / 10;
      } while (n &gt; 0);
  }
  </code></pre>
  
  <p>Problem is, when I input a number, it gets printed in the reverse order but there is a <code>0</code> in the end. For example if I give <code>12</code>, it gives <code>210</code> as output. I can't figure out what the problem is, so any help is appreciated. Regards.</p>