Related Articles

# GATE | GATE-CS-2015 (Set 1) | Question 45

• Difficulty Level : Expert
• Last Updated : 28 Jun, 2021

What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory.

 `#include ``int` `main()``{ ``   ``unsigned ``int` `x = {{1, 2, 3}, {4, 5, 6}, ``                           ``{7, 8, 9}, {10, 11, 12}};``   ``printf``(``"%u, %u, %u"``, x+3, *(x+3), *(x+2)+3);``}`

(A) 2036, 2036, 2036
(B) 2012, 4, 2204
(C) 2036, 10, 10
(D) 2012, 4, 6

Explanation:

```x = 2000

Since x is considered as a pointer to an
array of 3 integers and an integer takes 4
bytes, value of x + 3 = 2000 + 3*3*4 = 2036

The expression, *(x + 3) also prints same
address as x is 2D array.

The expression *(x + 2) + 3 = 2000 + 2*3*4 + 3*4
= 2036
```

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up