Q:
What would be the output of the following program?
main()
{
static int a[20];
int i = 0;
a[i] = i++;
printf ("\n%d%d%d", a[0], a[1], i);
}
Answer
0 0 1
That's what some of the compilers would give. But some other compiler may give a different answer. The reason is, when a single expression causes the same object to be modified and then inspected the behaviour is undefined.
View answer
Workspace
Report Error
Discuss