What will be the output of the following code?
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
}
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
}A. 0 0
B. Garbage value 0
C. 0 Garbage Value
D. Garbage vlaue Garbage Value
E. Code will not compile
Answer: Option D
Solution (By Examveda Team)
In c compiler does not check array with its bounds, value at the computed location is displayed.
Join The Discussion
Comments (6)
Related Questions on Arrays and Strings

answer should be garbage value and 0
0 12063648 answer that is why c is the write answer..
is negative indexing allowed in c
The output will be [ 0 Garbage Value ]
A range check is a check to make sure a number is within a certain range; for example, to ensure that a value about to be assigned to a 16-bit integer is within the capacity of a 16-bit integer (i.e. checking against wrap-around).
output is 0 0 not any garbage value