- Asked 2/16
- 2067 Asoj · 2 marks
- 2072 Kartik · 2 marks
Define structure; need of structures
Short answer
A structure is a user-defined data type that groups logically related variables of possibly different types under a single name. It is needed because arrays cannot hold mixed-type records; it keeps entity data together, enables whole-record assignment/parameter passing, supports arrays of records for databases, and forms the basis of linked lists, stacks, etc.
Define the structures in C programming. Explain the need of structures.
Definition
A structure is a user-defined data type in C which groups logically related variables, possibly of different data types, under a single name. Each variable inside is a member.
struct student {
char name[30];
int roll;
float marks;
};
struct student s1; /* variable */
Need of structures
- Arrays store only same-type data; a record (name, roll, marks) needs different types together.
- All data about one entity is kept together, so the program is easier to read and maintain.
- A whole record can be passed to or returned from a function, or assigned to another variable, in one step.
- An array of structures stores many records (e.g. 100 students), the basis of file records and databases.
- Structures are the building blocks of linked lists, stacks, queues and trees (with pointers).
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Nested structures with example · Computer Programming, chapter 8 · asked 7×
- Use of typedef with structures · Computer Programming, chapter 8
- Arrays within structures · Computer Programming, chapter 8
- Sort employee structures by salary · Computer Programming, chapter 8 · asked 2×
- Need of control statements · Computer Programming, chapter 5 · asked 2×
- Need of analysis and design · Computer Programming, chapter 2
- Project financing; structures; capital structure steps · Project Engineering, chapter 6
- Drop structures: need and types with sketches · Irrigation and Drainage Engineering, chapter 7 · asked 6×
- Uses and scope of masonry structures · Concrete Technology and Masonry Structure, chapter 7 · asked 5×
- Hill road drainage structures · Transportation Engineering I, chapter 5 · asked 4×