9.A) How does a structure differ from an array?
Answer:-
9. A) How does a structure differ from an array?
Answer :
Sl.no | Arrays | Structures |
1. | Array is a collection of related data elements of the same data type | Structure is the collection of logically related data elements of different data types. |
2. | Array is derived data type | Structure is a programmer-defined one |
3. | Array behaves like built-in data type | In case of Structures, first, we have to design and declare a data structure. |
4. | In Arrays we have to declare an array of variables and use them. | In structures after designing the structure and declaring then we can declare structure variables and use them. |
5. | syntax: data_type array_name[size]; | syntax: struct tag_name { datatype member1; datatypemember2; ————– ————– }; |
6. | Example: int marks[5]; | Example: struct book_bank { chartitle[20]; char author[15]; int pages; float price; }; |