Question discussion

What will be the output of the following code?void main(){ int a[10]; printf("%d %d", a[-1], a[12]);}

305949Medium 1 reply 1,121 views
0
What will be the output of the following code?void main(){ int a[10]; printf("%d %d", a[-1], a[12]);}
  • A0 0
  • BGarbage value 0
  • C0 Garbage Value
  • DGarbage vlaue Garbage Value
  • ECode will not compile
Correct answer: D

Discussion 1

0
CCommunity
Garbage vlaue Garbage Value

In c compiler does not check array with its bounds, value at the computed location is displayed.