Hello there!

First off, I'm just in school, 10th grade (second year of computer science), so I am not very advanced.

I was wondering...How can I write a simple program that does combinations, in a certain way?

Let's say I have 5 buttons. I want all combinations of pressed and unpressed buttons. X can be a pressed one, and 0 an non-presssed one. I want to make those combinations:

X0000

XX000

X0X00

X00X0

X000X

XXX00

XX0X0

XX00X

X0XX0

X0X0X

and so forth, making all the possible combinations with 1 X, then with 2 X'es, then with 3 and so forth.I can make 5 different programs for this (if the maximum is 5 Xes), using lots of "for", but I don't know how to make it all in one program, because no teacher will teach us stuff like this, because it isn't very usefull for the contests in my country.

With a bit of independent studiing, I think it should be backtracking or recursivity? I don't really know, I'm still a newbie :)

Sorry for my bad English, and thank you kindly if you read this.

PS: I've searched google before posting this, and I only found simple explanations for programs that can only solve this problem for a certain number of "X",and this I can allready do, and I want one that can do it for any number of "buttons", using from 1 X to maximum X's