title: Recursive function in C to determine if digits of an integer are sorted ascending, descending or neither
body: <p>I need to write a recursive function that returns 1 if digits of a whole number are ascending (left to right), return -1 if descending or return 0 if neither.</p>
  
  <p>My solution attempt returns 0 every time and I know why but I don't know how to get around it.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int check_order(int n)
  {
      if (n % 10 &gt; n / 10 % 10)
      {
          return check_order(n / 10);
          if (n == 0)
          {           
              return 1;
          }
      }
      else if (n % 10 &lt; n / 10 % 10)
      {
          return check_order(n / 10);
          if (n == 0)
          {
              return -1;
          }
      }
      else
      {
          return 0;
      }
  }
  
  int main()
  {
      int n;
      printf("enter a whole number (n &gt; 9):");
      scanf_s("%d", &amp;n);
      printf("function returned: %d\n", check_order(n));
  }
  </code></pre>