vendredi 24 avril 2020

Between random and undefined behaviour [closed]

I need an explanation for the following program behaviour inside a loop:

int f() { 
    return n%6+1; 
}
int main() {
    for(int i=0; i<100; i++)
        printf("%d",f());
}

It returns a first number then a second different numbers then it keeps returning the second nulber until we exit the loop!




Aucun commentaire:

Enregistrer un commentaire