1. How do you declare an array of 5 structures of type Person?
(A) Person arr[5];
(B) struct Person arr[5];
(C) Both A and B
(D) Person arr();
2. How do you access the name member of the 3rd element in the array arr?
(A) arr[2].name
(B) arr[3].name
(C) arr->name[2]
(D) arr.name[2]
3. How do you initialize an array of structures at the time of declaration?
(A) Person arr[2] = { {"Ali", 20}, {"Sara", 22} };
(B) Person arr[2] = Person{ {"Ali", 20}, {"Sara", 22} };
(C) Both A and B
(D) Person arr[2] = new Person;
4. Can you use a loop to access all elements of an array of structures?
(A) Yes
(B) No
(C) Only with pointers
(D) Only if static
5. How do you declare a pointer to the first element of an array of structures?
(A) Person *ptr = arr;
(B) struct Person *ptr = arr;
(C) Both A and B
(D) Person ptr = arr;
6. How do you access the age member of the 2nd element using pointer ptr?
(A) ptr[1].age
(B) (ptr+1)->age
(C) Both A and B
(D) ptr.age[1]
7. Can arrays of structures contain arrays as members?
(A) Yes
(B) No
(C) Only 1D arrays
(D) Only pointers
8. What is the correct syntax to declare an array of structures dynamically?
(A) Person *ptr = new Person[5];
(B) Person ptr = new Person[5];
(C) Person *ptr = malloc(sizeof(Person)*5);
(D) Both A and C
9. How do you free dynamically allocated array of structures?
(A) delete ptr;
(B) delete[] ptr;
(C) free(ptr);
(D) release(ptr);
10. Can an array of structures be passed to a function?
(A) Yes, by pointer
(B) Yes, by reference
(C) Yes, by value
(D) All of the above
11. How do you access members in an array of structures inside a function?
(A) arr[i].member
(B) ptr[i].member
(C) Both A and B
(D) member.arr[i]
12. Can a structure array contain nested structures?
(A) Yes
(B) No
(C) Only pointers
(D) Only dynamic arrays
13. How do you declare a 2D array of structures?
(A) Person arr[3][4];
(B) struct Person arr[3][4];
(C) Both A and B
(D) Person arr(3,4);
14. How do you access name of 2nd row, 3rd column element in a 2D array arr?
(A) arr[2][3].name
(B) arr[1][2].name
(C) arr[3][2].name
(D) arr[2,3].name
15. Can you assign one array of structures to another directly?
(A) No
(B) Yes, element by element
(C) Yes, whole array
(D) Only pointers
16. Which of the following is true for array of structures?
(A) Each element can be accessed individually
(B) Can be looped through
(C) Can be passed to functions
(D) All of the above
17. Can a structure array contain functions as members?
(A) Yes
(B) No
(C) Only static
(D) Only inline
18. How do you initialize only first element of an array of structures?
(A) Person arr[3] = { {"Ali",20} };
(B) Person arr[3] = Person{ {"Ali",20} };
(C) Both A and B
(D) Not possible
19. Can arrays of structures contain pointers to other structures?
(A) Yes
(B) No
(C) Only dynamic arrays
(D) Only 2D arrays
20. What is output?
struct Person { string name; int age; };
Person arr[2] = { {"Ali",20}, {"Sara",22} };
cout << arr[1].name;
(A) Ali
(B) Sara
(C) 22
(D) Compile error
21. Can array of structures be global?
(A) Yes
(B) No
(C) Only if public
(D) Only if static
22. Can a pointer point to an element of structure array?
(A) Yes
(B) No
(C) Only first element
(D) Only last element
23. Which is correct syntax to iterate array of structures using pointer?
(A) for(int i=0; i<5; i++) cout << (ptr+i)->name;
(B) for(int i=0; i<5; i++) cout << ptr[i].name;
(C) Both A and B
(D) Neither A nor B
24. Can arrays of structures be initialized partially?
(A) Yes
(B) No
(C) Only static arrays
(D) Only in functions
25. Which of the following is correct declaration of structure array with initialization?
(A) Person arr[3] = { {"Ali",20}, {"Sara",22}, {"John",25} };
(B) Person arr[] = { {"Ali",20}, {"Sara",22}, {"John",25} };
(C) Both A and B
(D) None
26. Can a structure array contain constant members?
(A) Yes
(B) No
(C) Only static
(D) Only private
27. Can you pass a 2D array of structures to a function?
(A) Yes
(B) No
(C) Only by reference
(D) Only by pointer
28. How do you access structure members in an array inside a function using pointer?
(A) ptr[i].member
(B) (ptr+i)->member
(C) Both A and B
(D) member[i].ptr
29. Can array of structures have constructors?
(A) Yes
(B) No
(C) Only static constructors
(D) Only inline constructors
30. Which of the following is true for arrays of structures?
(A) Can contain other structures
(B) Can have functions and pointers as members
(C) Can be dynamic or static
(D) All of the above