What will be printed after execution of the following code?
void main()
{
int arr[10] = {1,2,3,4,5};
printf("%d", arr[5]);
}
void main()
{
int arr[10] = {1,2,3,4,5};
printf("%d", arr[5]);
}
A. Garbage Value
B. 5
C. 6
D. 0
E. None of these
Answer: Option D
Solution(By Examveda Team)
When an array is partially initialized at the time of declaration then the remaining elements of the array is initialized to 0 by default.
Join The Discussion
Comments ( 3 )
Related Questions on Arrays and Strings
And the return type of main is int by default not void.
It will be garbage value according to GCC compiler
What will be printed after execution of the following code?
void main()
{
int a[5]={2,4,8};
printf(“%d”,a[5]);
}