Vote count:
0
pardon me if this is kinda stupid question, I've searched a lot but could'nt find the exact answer to this problem, here is a very simple code:
int main()
{
int i = 0;
while(i++ < 10)
printf("%d\n", i);
return 0;
}
The result is:
1
2
3
4
5
6
7
8
9
10
Why 0 is not the first number to print? And if I replace the i++ with ++i I'll get this:
1
2
3
4
5
6
7
8
9
For both i++ and ++i the first number is 1.
I expected to see the 0 for post increment in while loop while().
Thanks.
asked 21 secs ago
Post Increment in while loop in C
Aucun commentaire:
Enregistrer un commentaire