Hi!

I was just wondering if any one could show me some example of how a function of this would look like?

Heres the description:

Write a program with a minimum of a function, which is used to locate
and after returning x-th smallest number in an integer.
Ex: given that we have an original box with the contents: (8, 54, 62, 110, 299,
73, 1,
75, 12, 42)
With a call like: xth_smallest (MyArray, 4, array_size) would
function returns a value of 42nd

Hi!

I was just wondering if any one could show me some example of how a function of this would look like?

Heres the description:
Write a program with a minimum of a function, which is used to locate and after returning x-th smallest number in an integer. Ex: given that we have an original box with the contents: (8, 54, 62, 110, 299, 73, 1, 75, 12, 42) With a call like: xth_smallest (MyArray, 4, array_size) would function returns a value of 42nd

It is quite easy...
Use some kind of sort function. While doing the sort, count the x-th run of the algorithmus. Sort algorithmus is easy to find on net. Just add there the restriction.

Anyway do your homework alone, I have helped you enough.

Hi Seten and thanks for your quick answer!

This aint a homework (yet?) but for me to examine before my test next week, would really appreciate an snippet of code if I might call it that.

Thanks in advance
Adam

Hi Seten and thanks for your quick answer!
This aint a homework (yet?) but for me to examine before my test next week, would really appreciate an snippet of code if I might call it that.
Thanks in advance
Adam

Ok then add here a sort algorithmus that sort numbers by lowest to highest. Then we can adjust the algorithmus to do what you need. Google for "sorting algorithmus " .
Choose one and adjust it.

Anyway it would be a waste for you if I would give you the right answer or even a part of it, now.
Even so you have not shown any skills and this is a good example to check what you have learned.

If it should be not visible to public like homework then PM me the code and I will check it for you. But still I won't do it for you.

This article has been dead for over six months. Start a new discussion instead.