• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Quiz - 112 | Question 1

Pick the best statement for the below program: C
#include \"stdio.h\"

int main()
{
 struct {int a[2];} arr[] = {{1},{2}};

 printf(\"%d %d %d %d\",arr[0].a[0],arr[0].a[1],arr[1].a[0],arr[1].a[1]);

 return 0;
}

(A)

Compile error because arr has been defined using struct type incorrectly. First struct type should be defined using tag and then arr should be defined using that tag.

(B)

Compile error because apart from definition of arr, another issue is in the initialization of array of struct i.e. arr[].

(C)

Compile error because of initialization of array of struct i.e. arr[].

(D)

No compile error and it’ll print 1 2 0 0

(E)

No compile error and it’ll print 1 0 2 0

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments