mardi 24 avril 2018

if inside while loop c++

I am trying to make when user types number, program should repeat that many times chosing random if Here is my code

    while (c < d) {
    c = c++;
    num = (rand() % 3) + 1;
    if (num = 1) {
        system("start C:\\test\\vw");
        Sleep(2000);
    }
    else if (num = 2) {
        system("start C:\\test\\vw2");
        Sleep(2300);
    }
    else if (num = 3) {
        system("start C:\\test\\vw3");
        Sleep(1800);
    }

It always chooses to open first one and then stops.

Aucun commentaire:

Enregistrer un commentaire