Originally Posted by
litzkrieg
Adak if i remove the scanf() line how will the program know what the user has entered as far as number of variables?
Using bits or wheels, (either one), you're limited to 2 X the number of bits or wheels that you're using.
For instance, you can't have 16 numbers in bits, if you're only using 2 bits (same with wheels if wheels are representing those bits and limited to 0 or 1).
If you want all numbers less than 100, you can change your code to base 10 logic.
Code:
int main(void) {
int wheel1, wheel2, stop, num=0;
printf("How many number combinations do you want [1-99] ");
scanf("%d", &stop);
printf("\nResults: \n==============\n");
for(wheel1 = 0; wheel1<10;wheel1++) {
for(wheel2 = 0; wheel2<10;wheel2++)
printf("%d%d\n",wheel1, wheel2);
if(++num > stop)
break;
}
if(num>stop)
break;
}
return 0;
}
Which will produce:
Results:
============
00
01
02
. . .
09
10
11
. . .
99
If stop equals 100