Nearby lessons
103 of 124C - Arrays of Structures
Arrays of Structures is one of the foundational topics in C programming. This lesson explains Program 4: Array of Structures (Many Students) with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
Program 4: Array of Structures (Many Students)
Just like an array of ints, you can have an array of structures — for many students:
Notice the pattern s[i].rollNo — first the index, then the member.
In simple words: an array of structures is a class register — the index picks the student, the member picks the detail. s[2].marks means the marks of student number 2.
Example01
📝 Key Takeaways
- Structure groups different types under one name — like a form.
- Define the template, declare variables, access members with the dot.
- Separate programs: access, one-line init, user input, arrays of structures.
- Structures can nest inside structures.
- Union shares one memory for all members; structure gives each member its own.
- sizeof(union) = largest member; sizeof(struct) = sum of members.
🧠 Test Your Knowledge
1 QuestionsProgress: 0 / 1