title: Finding Prime and Composite Elements in an array. Print primes in ascending order and composite in descending order
body: <p>I am successful in identifying prime and composite from an array. But my <code>qsort</code> function seem to not have any effect when I print the output. I need the primes to be ascending and composite to be descending. When I run the code, it does not sort the output, though it identifies primes and composites.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int compare_Asc(const void *a_void, const void *b_void) {
      int a = *(int *)a_void;
      int b = *(int *)b_void;
      return a - b;
  }
  
  int compare_Desc(const void *a_void, const void *b_void) {
      int a = *(int *)a_void;
      int b = *(int *)b_void;
      return b - a;
  }
  
  int main() {
      int i = 0, n, x, p, c, z, w, j = 0, k = 0, cmpst, null;
      int prm;
      int prime[50], composite[50], input[50];
      printf(&quot;How many inputs are you be working with?\nNote: 50 Maximum Inputs\n&quot;); 
      scanf(&quot;%d&quot;, &amp;n);
      printf(&quot;Enter the numbers.\n&quot;, n);
      
      for (i = 0; i &lt; n; i++) {
          scanf(&quot;%d&quot;, &amp;input[i]);;
      }
      for (i = 0; i &lt; n; i++) {
          if (input[i] % 2 != 0) {
              prime[p++] = input[i];
              prm = p;
          } else
          if (input[i] &gt;= 2 &amp;&amp; input[i] % 2 == 0) {
              composite[c++] = input[i];
              cmpst = c;
          }
      }
      printf(&quot;Prime Numbers:&quot;); 
      qsort(prime, prm, sizeof(int), compare_Asc);
      for (i = 0; i &lt; p; i++) {
          printf(&quot;%d&quot;, prime[p]);
      }
      printf(&quot;Composite Numbers:&quot;); 
      qsort(composite, cmpst, sizeof(int), compare_Desc);
      for (i = 0; i &lt; c; i++) {
          printf(&quot;%d&quot;, composite[c]);
      }
      return 0;
  }
  </code></pre>