ExamVeda
Login
Home
This question belongs to C Program Arrays And Strings
Arrays and Strings
?

What will be printed after execution of the following code?
void main()
{
      int arr[10] = {1,2,3,4,5};
      printf("%d", arr[5]);
}

Answer & Solution
Correct Answer: Option D

When an array is partially initialized at the time of declaration then the remaining elements of the array is initialized to 0 by default.

Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
Amit Verma
Amit Verma 4 years ago
And the return type of main is int by default not void.
Amit Verma
Amit Verma 4 years ago
It will be garbage value according to GCC compiler
Utsav Patel
Utsav Patel 5 years ago
What will be printed after execution of the following code?
void main()
{
int a[5]={2,4,8};
printf(“%d”,a[5]);
}