What is printed by the following ANSI C program?

#include<stdio.h>
int main(int argc, char *argv[])
{
int x = 1, z[2] = {10, 11};
int *p = NULL;
p = &x;
*p = 10;
p = &z[1];
*(&z[0] + 1) += 3;
printf("%d, %d, %d\n", x, z[0], z[1]);
return 0;
}
A.

1, 10, 11

B.

1, 10, 14

C.

10, 14, 11

D.

10, 10, 14

Solution:

Initially, x = 1, z = {10, 11}

p is pointing to x, updated value of x = 10.

p is pointing to the 2nd element of array z.

*(&z[0] + 1) += 3;  // This statement will add 3 to second element of array z.

After execution, updated values are x = 10, z = {10, 14}

This program will print 10, 10, 14

Correct answer is Option D.