title: Recursive functions in C and printf
body: <p>So, first of all I'm a total beginner in C, we're studying it at University on the course 'Structured Programming'.</p>
  
  <p>Now, the last few lectures about 'Recursive functions' have been a pain for me as a beginner. Could anyone of you be kind enough to explain me this:</p>
  
  <p>So I have this little script, a recursive function that takes a decimal number and converts it to a binary one:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void binary(int num)
  {
      if (num == 0) return;
  
      binary(num / 2);
      printf("%d", num % 2);
  }
  
  int main()
  {
      int n;
      scanf("%d", &amp;n);
      binary(n);
      return 0;
  }
  </code></pre>
  
  <p>Now I was wondering, how does this function work? I know the logic behind it and whats its supposed to do, but I don't know how it does IT. The printf in the bottom is especially throwing me off, for example if the printf function is before the recursive call, for the input decimal 10 it prints out (0101) but if its under it it prints out the correct binary number (1010)?</p>
  
  <p>Any kind of help is greatly appreciated, kind regards. </p>