samedi 30 octobre 2021

how to check for positive multiples of 2 using modulus operator in an if loop

I was trying to use the mod % operator in C++ but it shows the error Expression is not assignable

int i = 0;
    cin>>i;
//    for (i; i < 25; i++) {
        if (i < 25 && i % 2 = 0) {
            cout<<"test"<<i;
        } else {
            cout<<"test2"<<i;
        }
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire