mercredi 2 septembre 2020

While loop cout not printing 8 times [closed]

void DrawStairs() {
// Declare Variable i
int i = 0;

// while loop 
while (i == 0){
    //Increment Variable 
    i + 1;
    //Print # (Should print 8 times but it's not)
    cout << "#\n";
    if (i == 8)
        break;        
}
printf("\n\n\n\n\n\n\n\n\n\n%d", i);

The code above on compiler explorer just prints # forever. If i change the if to if (i = 8) Then it will break when i = 8 but it will only print # once. I want it to print # 8 times. How do I accomplish this?

Aucun commentaire:

Enregistrer un commentaire