Array of structures — C++ MCQs

30
Score: 0
Attempted: 0/30
1. How do you declare an array of 5 structures of type Person?



2. How do you access the name member of the 3rd element in the array arr?



3. How do you initialize an array of structures at the time of declaration?



4. Can you use a loop to access all elements of an array of structures?



5. How do you declare a pointer to the first element of an array of structures?



6. How do you access the age member of the 2nd element using pointer ptr?



7. Can arrays of structures contain arrays as members?



8. What is the correct syntax to declare an array of structures dynamically?



9. How do you free dynamically allocated array of structures?



10. Can an array of structures be passed to a function?



11. How do you access members in an array of structures inside a function?



12. Can a structure array contain nested structures?



13. How do you declare a 2D array of structures?



14. How do you access name of 2nd row, 3rd column element in a 2D array arr?



15. Can you assign one array of structures to another directly?



16. Which of the following is true for array of structures?



17. Can a structure array contain functions as members?



18. How do you initialize only first element of an array of structures?



19. Can arrays of structures contain pointers to other structures?



20. What is output?
struct Person { string name; int age; };
Person arr[2] = { {"Ali",20}, {"Sara",22} };
cout << arr[1].name;




21. Can array of structures be global?



22. Can a pointer point to an element of structure array?



23. Which is correct syntax to iterate array of structures using pointer?



24. Can arrays of structures be initialized partially?



25. Which of the following is correct declaration of structure array with initialization?



26. Can a structure array contain constant members?



27. Can you pass a 2D array of structures to a function?



28. How do you access structure members in an array inside a function using pointer?



29. Can array of structures have constructors?



30. Which of the following is true for arrays of structures?



Contents Copyrights Reserved By T4Tutorials