Teacher wants source Code of qsort function????

Please help me, I have an A riding on this question. I turned in an assignment for school whereas I was asked to get 8 integers from an individual and then sort them in descending order. With the assistance of some great people in this forum, I was able to do that. NOW, I get my grade back and here are my teacher's comments:

Although your week 5 program works, you used provided qsort function. The purpose of this assignment is to ask you to figure out the way of how to sort numbers. I know you are going to argue that I did not indicate that you cannot use qsort function. If you include the source code of qsort function in your code, this will be acceptable.

So, I am gathering from that that if I resubmit with the "source code" for the qsort function, he will modify my grade. Ok, so here is the assignment I turned in. If ANYONE can help me out, I would be so grateful...

I Googled qsort source code and nothing came up really clear for me. I am assuming that what he is looking for is that I actually put the qsort function into the program. Is that what you take from his comment?

I take it that your instructor wants you to write your own sorting algorithm and not use one of the standard library functions. There are quite a few algorithms that you could use. google for "quicker sort" or "sort algorithms". Here are some for java

This is great, a bit above my head, but great. Question: Can I just plug this into my program as it is presented up above?

yes, not very difficult but laborious.dont include, make an object and link it w/ your prog
so you can reuse it in other projects.
you sure need forwards declarations and ....
at least make some changes (coustomize)
avoid possible side effects, rewrite things like:

I would suggest that your professor want you to have wrapped your head around a sorting process, even if it's the most inefficient kind of bubble one might devise.

Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.

Just a short note on bubble sort vs qsort (or any other). If you have a small number of elements (in my experiments in the past, 'small' was 500-1000 elements), the bubble sort is just as fast or faster than qsort, so just because bubble sort is deemed sloppy and inefficient by sorting experts, it is a perfect solution for small problems.

It seems probable to me that your prof. will recognise that you cribbed this code from elsewhere.

I think that he has continued to be unclear, because I cannot believe that he really meant you to simply reproduce the source to the library code.

If you really want that 'A', you will need ot do a little more work that that. I doubt that he is looking for an elegant or efficient algorithim, just some evidence that you know how to manipulate data.

Because qsort uses a pointer to the compare function, I suggest that you produce something simpler and less generic in this case - specific to sorting integers.

A note from experience on the quicksort: TEST ALL CONDITIONS!!! do not blindly copy from what you find on google. I found a few algorithms put out by decently-looking tutorials and they produced wrong output, actually it was quicksort that was not working for several cases.

You could tell the teacher that there are plenty of qsort source code routines on the web. For example, Free, Net and Open BSD all make their qsort source available on the web. Simply point your teacher to that source.

i am amazed that your instructor did not recognize that you used the qsort function from the library. you could simply tell him that is what you did, then ask for an extra few days to code your own sort function.

try Bubble sort

I think that the point of the course is not to use the libraries but to create a sorting mecanism for yourself. Take the array of numbers entered and
check their values; print them back sorted. I sure that you can do it without qsort. In my first computer course they don't let us use the libraries, in my second course they did because we have other things to worry about, more complicated stuff. ;)