title: Reverse the output of printf function in while loop
body: <p>I wrote a code for a b-adic representation of a chosen number.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int b_adisch (int a, int b)
  {
  
      int x, y, mod, mod1;
  
      x = a / b;
      mod1 = a % b;
  
      printf("%i\n", mod1);
  
      do {
      y = x / b;
      mod = x % b;
      x = y;
      printf("%i\n", mod);
      } while(x != 0);
      return a ;
  }
  
  int main (void)
  {
      int a, b;
      printf("pls input a ");
      scanf("%i", &amp;a);
      printf("pls input b ");
      scanf("%i", &amp;b);
      b_adisch(a, b);
  
      return 0;
  }
  </code></pre>
  
  <p>The output order will be reversed 
  since the printf has to be put into the while loop and the calculation starts with the last number of the representation.</p>
  
  <p>Example if a = 10 and b = 2<br>
  The output is 0101<br>
  but it should be 1010</p>
  
  <p>How can I change my code to make this happen?     </p>