I have made this small text-based casino game in C++. How could I improve it? Be as picky as you'd like.#include <iostream>#include <cstdlib>#include <ctime>using namespace std;// General functionsvoid bankrupt();// Roulette functionsvoid roulette01();void roulette02();void rouletteWin();void rouletteLoss();// Slots functionsvoid slots01();void slots02();// General variablesint invalid = 1;int input;int dollars = 50;// Roulette variablesint bet = 0;char cColour;int iColour;int actualColour;// Slots variablesint randSlots01;int randSlots02;int randSlots03;int main() {    srand (time(NULL));    while (invalid == 1) {        system(cls);        cout << \n Welcome to the Casino! What would you like to play? << endl;        cout << \n 1. Roulette << endl;        cout << \n 2. Slots << endl;        cout << \n 3. Exit << endl;        cout << \n> ;        cin >> input;        switch (input) {            case 1:                input = 1;                roulette01();            case 2:                slots01();            case 3:                exit(0);            default:                cout << \n That was invalid input! << endl;                cout << \n ;                system(pause);                invalid = 1;        }    }}void roulette01() {    if (dollars <= 0) {        bankrupt();    }    system(cls);    cout << \n Roulette << endl;    cout << \n You have  << dollars <<  dollars! << endl;    cout << \n Enter 1 to place a bet. Enter 2 to exit to the main menu. << endl;    cout << \n> ;    cin >> input;    switch (input) {        case 1:            roulette02();        case 2:            main();    }}void roulette02() {    cout << \n Enter how much you would like to bet. << endl;    cout << \n> ;    cin >> bet;    if (bet > dollars) {        cout << \n You don't have enough money for that bet! << endl;        cout << \n ;        system(pause);        roulette02();    }    cout << \n Would you like to bet on red or black? << endl;    cout << \n Enter r for red. Enter b for black. << endl;    cout << \n> ;    cin >> cColour;    if (cColour == 'r') {        iColour = 1;    }    else {        iColour = 2;    }    actualColour = rand() % 2;    if (actualColour == iColour) {        rouletteWin();    }    else {        rouletteLoss();    }}void rouletteWin() {    dollars = dollars + bet;    cout << \n You won  << bet <<  dollars! << endl;    cout << \n ;    system(pause);    roulette01();}void rouletteLoss() {    dollars = dollars - bet;    cout << \n You lost  << bet <<  dollars! << endl;    cout << \n ;    system(pause);    roulette01();}void slots01() {    if (dollars <= 0) {        bankrupt();    }    system(cls);    cout << \n Slots << endl;    cout << \n You have  << dollars <<  dollars! << endl;    cout << \n Enter 1 to play. Enter 2 to exit to the main menu. << endl;    cout << \n> ;    cin >> input;    switch (input) {        case 1:            slots02();        case 2:            main();    }}void slots02() {    randSlots01 = rand() % 3;    randSlots02 = rand() % 3;    randSlots03 = rand() % 3;    if (randSlots01 == randSlots02 && randSlots02 == randSlots03) {        dollars = dollars + 10;        cout << \n You won 10 dollars! << endl;        cout << \n ;        system(pause);        slots01();    }    else {        dollars--;        cout << \n You lost 1 dollar! << endl;        cout << \n ;        system(pause);        slots01();    }}void bankrupt() {    dollars = 50;    cout << \n You have gone bankrupt! Time to start over. << endl;    cout << \n ;    system(pause);    main(); }
Text-based casino game
c++;game
Your naming needs a lot of work. In particular it's a very bad idea to name your entities with numeric suffixes, as that doesn't explain at all what they're doing (it shows they're related but not how, and definitely not how they differ from each other in function).All your variables are global. This is very bad form. Variables should have the smallest possible scope, so it's plainly evident where they're used and what they're used for. There are a number of ways to deal with global state; but at this level there probably should just be a struct that gets passed around.You've got some unnecessary code. There's no reason for input = 1; in the first case.You shouldn't use exit(0) unless you have a reason to. return works perfectly well for returning from main().Don't rely on system() for controlling the user interface. It makes your code impossible to port. At the very least, make helper functions for each of the tasks so that you just have to replace the code once in each helper function.Your program crashes if the user does not input an integer at the main menu.The sub-functions, roulette01() and slots01(), should not call main(). main() already has a loop in it, so you can just return; from them to get back to main().Similarly, roulette01() and slots01() should be structured to include a loop, so that you don't have functions recursively calling each other.Ideally you ought to completely separate the logic of each game from the user interface. One function does the logic, another function calls it and displays the results.