dimanche 15 novembre 2020

if statement with modulo operator inside for loop [closed]

int i;
for(i=10;i<=20;i=i+2)
    if(i%10 <= 5)
        printf("hello\n");

Why is "hello" printed four times? I expected it to be three times. Is it because of precedence?

Aucun commentaire:

Enregistrer un commentaire