title: Recursive function that prints all integers from N to 1 and then from 1 to N
body: <p>I just wanted to ask how i can display all integers from N to 1 and again to N with step -+2 and a recursive function, considering that N is given by user. For example, if the user gives 7, then calling the function would print &lt;&lt;7 5 3 1 3 5 7>> or if the parameter is 8, it would print &lt;&lt;8 6 4 2 4 6 8>> I have only figured out to display N to 1 (or N to 2). Here's my code:</p>
  
  <pre><code>    int main()
  {
      int a;
      printf("Give a:");
      scanf("%d", &amp;a);
      func(a);
      return 0;
  }
  
  int func(int n)
  {
      printf("\t%d",n);
      if (n==1 || n==2)
      {
          return 1;
      }
      return func(n-2);
  }
  </code></pre>