Obtaining all combinations of elements...

Greetings. I am new to this board, but I'll try to be as clear as possible.

Here's the deal. Suppose I have the following array:

Code:

`int old_array [] = {1,2}`

I want to obtain a bidimensional array from that array, with the following elements:

Likewise, if I had:

Code:

`int old_array [] = {1,2,3}`

I'd want to obtain:

Code:

`{{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}`

So, basically, I'm searching for an algorithm that allows me to obtain every single possible combination of elements from the old array: every combination of 1 element, every combination of 2 elements, and so forth.

Thus, I have two questions:

1) I know that what I want to obtain has a specific mathematical term in English, but what is that term exactly?

2) Do you happen to know how I can code such algorithm? If so, how?

Thank you in advance. I hope I've made myself clear enough.