jeudi 28 mars 2019

how do I use else and if statements

both of my options are coming up when I run the code

I have tried two if statements else if and else

cout << "would you like to hit or stand?" << endl; //asking if you would ike to hit or stand

bool hit; //the hjitting opption
bool stand; // the stand / hit option

cin >> hit, stand; // the avaiabillity for hitting or standing (player input)
if ( hit = true) // if you hit
{
    for (n = 1; n <= 1; n++) //loop for how many cards are you have
    {
        num = rand() % 13; //get random number
        cout << num << "\t"; //outputting the number
    }
}

{
    cout << "you stand \n"; // saying you stand

I expect the code to output the number when u say hit and say you stand when you say stand but it is out putting either just the hit just the stand or bothenter code here

Aucun commentaire:

Enregistrer un commentaire