Looking at this again, I think that perhaps there have been more questions than answers for much of this thread. Hopefully I can clear a few of these up:
QUOTE
this thing can be done using a simple switch statement with a do while loop....just try it out
Switch statements are generally a good choice if you are dealing with different blocks of code for different integral values of a control variable. However, if you need to execute statements based on a
range of potential values, it is frequently more efficient (at least in terms of the number of lines of code you have to write) to use if statements with relational expressions, combined with boolean operators - as the OP has done here.
QUOTE
1 thing tho. I dont see him declaring A B etc. Or is int acounter =0; also declaring A?
the declaration of acounter does not also declare a variable A. In this case, the "A", "B", etc values shown in the output stages are string literals. Because they are literals, rather than variables, they don't need to be declared. You can tell if something is a literal because it will be either a straight numerical value, for numerical literals (e.g.
cout << 2;), it will be enclosed in single quotes, for literal characters (e.g.
cout << 'A';), or it will be enclosed in double quotes, for string literals (e.g.
cout << "string";).
QUOTE
QUOTE
I have a question, shouldnt that random() method be seeded with the time or something?
If you want it to be slightly more "random" yes. You can use it like that, its just really predictable.
aceofspades686 is right on this one - the builtin rand() function is actually pretty terrible as far as pseudo-random number generators go, and seeding it with the current system time will only slightly improve things. However, that really isn't critical unless you're dealing with encryption and stuff like that - it should be fine in cases like this where you really just need a sequence of numbers taken from a range, and you aren't worried about statistical correlation between sequentially generated numbers, distribution in space, etc. If you want a decent generator, check out the C++ snippets section- there are a couple of implementations of "good" RNGs there.
I hope that helps to clarify some of the issues that this thread has brought up.
-jjh