srand only needs be executed once. The examples I'm giving are only to demonstrate a concept and can't be compiled.
1 2 3 4 5 6 7 8 9 10 11 12
|
int main (void) {
srand (time(NULL));
do {
int Roll = rand () % 37; // Generate numbers between 0 & 36.
// Code here to place bets
// to determine wins
} while ( choice != 'Q' );
return 0;
}
|
#2 is not a method I would use although most often you'll see
or even while (true). That is the proper way to do an infinite loop when you need one, but that for/next inside a case is totally meaningless.
Try to avoid redundancy and in your case because you want to display "x" each time, put it outside switch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
do {
int Roll = rand () % 37; // Generate numbers between 0 & 36.
cout << x << endl;
cin >> choice;
toupper (choice);
switch (choice) {
case 'O':
break;
case 'E':
break;
case 'T':
break
case 'Q'
break;
default:
cout << "Not a valid choice" << endl;
}
} while ( choice != 'Q' );
|
Formating; This is just a rough draft to get thoughts on the screen. I usually indent and space properly after I get what I need on the screen.
|
Sounds logical, but trust me, when your apps get more complex, mismatched braces become a big problem and not being able to see program flow easily is another, it only takes seconds to hit TAB and if you use an editor like NotePad++ it's even easier.
That conditional probably should look something like this
if (x <20 && x >=0)
is probably what it should be.
I changed this to the recommended t, c, b but dont know what you mean by the numbering?
|
Don't worry about that, just get your original ones like O, E, Z & Q working first, then you'll see how to implement others.
I'm really curious as to how somebody that isn't a programmer can teach you programming and if in fact you are copying out of a book, verbatim without any mistakes, throw that book away.