title: Median Function In C
body: <pre><code>int findMedian (int argc, char** argv){
  
      int temp;
      for(int i=0; i&lt;argc; ++i) { /// bubble sort the array
          for(int j=i+1; j&lt;argc ; ++j) {
              if(argv[i] &gt; argv[j]) {
                  temp = atoi(argv[i]);
                  argv[i] = argv[j];
                  *argv[j] = temp;
              }
          }
      }
      int Median;
      if(argc %2 == 0){///if is even amount of number, take the mean of middle two number
  
          Median= ((atoi(argv[argc / 2 ])+ atoi(argv[argc / 2 + 1])) /2);
      }
      else{ /// if is odd amount of number, take the middle number.
          Median = atoi(argv[argc / 2 + 1 ]);
      }
      return Median;
  }
  </code></pre>
  
  <p>My median function will give me a median that is not sorted. anyone know why?
  Thanks for the help.</p>