How does a structure differ from an array?

9.A) How does a structure differ from an array?

Answer:-

9. A) How does a structure differ from an array?

Answer :

Sl.noArraysStructures
1.Array is a collection of related data elements of the same data typeStructure is the collection of logically related data elements of different data types.
2.Array is derived data typeStructure is a programmer-defined one
3.Array behaves like built-in data typeIn 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;
};

Leave a Reply

Your email address will not be published. Required fields are marked *