Generating number combinations

This is a discussion on Generating number combinations within the C Programming forums, part of the General Programming Boards category; so i need to generate the numbers for the rows on a k-map for a user selected up to 10 ...

Generating number combinations

so i need to generate the numbers for the rows on a k-map for a user selected up to 10 total variables meaning 5 digits on the row headers, EX. user enters "4" for the total amount of variables and the program would display:
"00
01
11
00"

and im not so much confused on the programing side of it but more how to design a program to do this just looking for some helping ideas.
Is there maybe a way for the ser to enter the max number 5 and have the program generate all possible binary combinations for 5 binary bits? thats kinda what i have thinking so far
thanks guys.

If I understand correctly, you prompt for a specific number, then take that number of bits and show all combinations. If that's right then you have to compute all numbers from 0 up to 2^n -1 in binary. So, write a decimal to binary conversion function and then compute all the necessary numbers.

Think of the odometer in a car - smallest "wheel" is turning up to 9, then it resets to 0, and turns the digit just to it's left, up by one number.

Your "odometer" will only go to 1, before resetting and incrementing the digit on it's left hand side. You could simulate this with two for loops, nested together, quite nicely - but you don't have to. Think of the binary numbering system. Each integer will have 16 or 32 "wheels", that it uses, ready for your use.

We call them bits.

When you increment an integer, you "turn" the "odometer" of the 16 or 32 "wheels" (bits), just as you need them, for this program.

so how could i use those for loops, ive been messing around for a bit now with ++ lines to incrment by one each time but just cant get it, how would those be stated, this is sad but this is what i have so far after a million and one failed attemps, how could i use those for loops though?

#include ....
int main(void) {
int wheel1, wheel2;
for(wheel1 = 0; wheel1<2;wheel1++) { //start of the first for loop for wheel1
//add your second for loop for wheel 2 right here
//now print out your wheel1 and wheel2 variables
} //end of second for loop
} //end of first for loop
getchar(); //hold the console screen open
return 0;
}
In practice, I'd never put a lowercase l next to a 1 in a variable, because they look too much alike. i'd use "w1, w2 ", etc.

ok well maybe because its late where i am but i can get it to compile and im just not sure but does that for loop statement really take care of all the combinations? i guess now that ive gotten to work on it before bed a bit im still confused on how to correctly format this.
here is what i have

There must be a typo there as you have two 00's.
Do you want the output in increasing binary order (00, 01, 10, 11),
or do you want gray code order (00, 01, 11, 10) which what you typed looks closest to?