+ 2
What is output of these code and how?
#include <stdio.h> int main() { int i=2; printf("%d, %d\n", ++i, ++i); return 0; }
2 odpowiedzi
+ 5
I checked this code and output is found to be 4,4.
I think this is because comma operator works from left to right. So, the output is twice incremented in both cases.
+ 1
if you run that
#include <stdio.h>
int main()
{
int i=2;
printf("%d, %d, %d\n", ++i, ++i, i++);
return 0;
}
result is 5,5,2 so the reason of these results is that before to show, compiler run operations ++i as theory said