Examveda
Examveda

What will be the output of the following code?
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.


This Question Belongs to C Program >> Arrays And Strings

Join The Discussion

Comments ( 6 )

  1. Amrutha P
    Amrutha P :
    4 years ago

    answer should be garbage value and 0

  2. Daniyal Ansari
    Daniyal Ansari :
    4 years ago

    0 12063648 answer that is why c is the write answer..

  3. Addanki Siva
    Addanki Siva :
    5 years ago

    is negative indexing allowed in c

  4. Abbas Ahmad
    Abbas Ahmad :
    6 years ago

    The output will be [ 0 Garbage Value ]

  5. Oma Choudhary
    Oma Choudhary :
    6 years ago

    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).

  6. Oma Choudhary
    Oma Choudhary :
    6 years ago

    output is 0 0 not any garbage value

Related Questions on Arrays and Strings