Programming Questions


What would be the output of the following program?



    static int a[20];

    int i = 0;

    a[i] = i++;

    printf ("\n%d%d%d", a[0],  a[1], i);



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.

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2267