I'm not going to answer your question completely, since I think it is homework and also think that this is easily done. But I do think that I know why you are having difficulty with an answer, so I will help you out a little bit.
Firstly, you should look into recursion. That means calling a function from within itself.
Second, you should use a helper function, which is called by the function you want to write. This function should take as arguments:
- an array of numbers
- the length of the array
- the value you want find members that sum up to
- the number of members of the array that you want to sum up
This function will be called by your other function and passed a 4 for the last argument. It will then call itself adjusting the arguments as it tries to find results by partial trial and error.
edit 2
Upon further thought I realized that this not O(n^2), as I claimed earlier (I mentally glossed over the the middle steps). It is limited by n^4, but may have a lower limit than that due to ample opportunity to short cut in many cases. I do not believe that this short cutting improves it to the point of n^2, though.