The first thing to note is there is always a better way to do something. I have never gone back to software and found it perfect even after tweaking it for years.
As for best practices:
1. You repeat a lot of code especially in regards to couts. Try to put your CARD GAME couts in to one method. You can use a parameter for the RED or BLUE CARD GAME.
2. Placebet can be a separate method. That way all you need to do in your main code is:
1 2 3
|
while(z==1){ // or while(true)
placeBest();
}
|
- GOTO can always be avoided, it makes code harder to read and can often end up in infinite loops or random crashes.
3. Rather than testing for both Red and Blue you could convert the inputted text to uppercase and check for RED or BLUE. Or just check the first uppercase character e.g. if(x[0]=='R') for red
4. After your if e < 101 condition you could use else if(e > 101) instead of just if e > 101.
Or you could call continue at the end of the e < 101 block. That way you do not need the condition e > 101.
5. Another best practice is to use as many constant values as possible rather than straight typed text. e.g. #define REDINPUT "RED"
Remember a customer doesn't care how your code is written though. If it works and works well, then its fine.