Unit 6 of MAKAUT C Programming (PPS-II) covers composite data aggregation via structures (struct), unions, bitfields, pointer to structures, and structure memory alignment.

In MAKAUT semester exams, questions on Structure Memory Padding and full code implementations of a Student Database & Marksheet Grade System are mandatory items in Group C (15 Marks).

---

1. Introduction to User-Defined Data Types

While arrays are homogeneous (all elements of identical data type), a struct enables heterogeneous data aggregation under a unified name.

c

---

2. Accessing Structure Members: . vs ->

  • Dot Operator (`.`): Used when accessing members via a structure variable (s1.rollNo).
  • Arrow Operator (`->`): Used when accessing members via a structure pointer (ptr->rollNo \equiv (*ptr).rollNo).

---

3. Structure Memory Alignment & Padding Explained

To optimize 32-bit/64-bit CPU word alignment, compilers insert unused padding bytes between structure fields.

c

Size of struct Example equals 8 Bytes, not 5 Bytes!

To force exact packing without padding, use #pragma pack(1):

c

---

4. struct vs union Comparison

Feature`struct``union`
Memory AllocatedSum of sizes of all members + paddingSize of largest member only
Member AccessAll members accessible concurrentlyOnly one member accessible at a time
Keywordstructunion

---

5. Solved MAKAUT Exam Programs

Program 1: Student Information System (Nested Structures)

c

---

Program 2: MAKAUT Comprehensive Student Marksheet & Grade System

*Exam Context: Group C (15 Marks)*

c