title: How write a program which print recursively
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12890621/how-write-a-recursive-print-program">How write a recursive print program</a>  </p>
  </blockquote>
  
  
  
  <p>I have already asked this question, but it was closed because of insufficient information.
  <a href="https://stackoverflow.com/q/12890621/1746220">How write a recursive print program</a></p>
  
  <p>Gurus,</p>
  
  <p>I want to know how to write a recursive function that prints </p>
  
  <p>1 <br>
  12<br>
  123<br>
  1234<br>
  ...<br>
  ......<br>
  <br>
  For eg: display(4) should print </p>
  
  <p>1<br>
  12<br>
  123<br>
  1234<br></p>
  
  <h2>Code</h2>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void print(int n)
  {
          if(n != 0)
          {
                  print(n-1);
                  printf("\n");
                  print(n-1);
                  printf("%d",n);
          }
  }
  int main()
  {
          print(3);
  }
  </code></pre>
  
  <p>Output
  <br>
  1<br>
  <br>
  12<br>
  <br>
  123<br></p>
  
  <h2>Issues</h2>
  
  <p>I wanted to write a pure recursive function but unable to filter unwanted prints.
  Hope someone will help me out!!!</p>