Multiple choice technology programming languages

What would be the output of the following program? main() { int a[5] = {2,3};; printf("\n%d %d %d", a[2],a[3],a[4]); }

  1. Garbage values

  2. 2 3 3

  3. 3 2 2

  4. 0 0 0

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In C, when you partially initialize an array, all remaining elements are automatically set to 0. The array a[5] = {2,3} means a[0]=2, a[1]=3, and a[2], a[3], a[4] are all 0. The extra semicolon is a harmless empty statement.