Why does these snippets give different results? I know the first one is correct, but what happens in the second case?
Sample 1
int i=0;
for(;i<5;i+=3){i=i*i;cout<<i;}
cout<<i;
Output:
0
9
12
Sample 2
for(int i=0;i<5;i+=3){i=i*i;cout<<i;}
cout<<i;
Output:
0
9
9
Aucun commentaire:
Enregistrer un commentaire