C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 9)
9.
What is the output of the program
#include<stdio.h>
int main()
{
    int a[5] = {2, 3};
    printf("%d, %d, %d\n", a[2], a[3], a[4]);
    return 0;
}
Garbage Values
2, 3, 3
3, 2, 2
0, 0, 0
Answer: Option
Explanation:
When an automatic array is partially initialized, the remaining elements are initialized to 0.
Discussion:
38 comments Page 4 of 4.

Harry said:   1 decade ago
@Vidya Because you use only 3 %d in the printf line.

Sahil said:   7 years ago
I think it should have garbage value. Right?

Saikumar Reddy said:   7 years ago
Give me an another example for this answer.

Sonam said:   8 years ago
Please explain, how can be solve this?

Srav said:   1 decade ago
What is partially initialization ?

Ravali said:   1 decade ago
What is an automatic array?

Raja Ravi said:   7 years ago
What is automatic array?

Rish said:   9 years ago
Thanks @Raghav.


Post your comments here:

Your comments will be displayed after verification.