'Any amount' is a bit pretentious (you've not such a computational power...). Anyway, you may do better than you did, though you've to go recursive ("
To Iterate is Human, to Recurse, Divine" - L. Peter Deutsch):
void seq(char * str, unsigned int level, unsigned int depth)
{
for (char c='A'; c<='Z'; c++)
{
str[level]=c;
if ( level == depth-1 )
printf("%s\t",str);
else
seq(str, level+1, depth);
}
}
const int MAX_DEPTH = 10;
void main()
{
char str[MAX_DEPTH+1] = {0};
unsigned int depth;
printf("enter a number between 1 and %d: ", MAX_DEPTH );
if (scanf("%u", &depth) != 1)
return;
depth %= MAX_DEPTH;
seq(str,0, depth);
}
As Rajesh already noted, the choice between
C
or
C++
, is irrelevant here.
:)