1.

Compare the aspects of arrays and structures.

Answer»

Array-:

An array is a collection of elements with same data type Or with the same name we can store many elements, the first or second or third etc can be distinguished by using the index(subscript). The first element’s index is 0, the second elements index is 1, and so on.

To store 100 numbers the array declaration is as follows

int n[100]; By this we store 100 numbers. The index of the first element is O and the index of last element is 99.

Structure -:

But a Structure is a group of different types of Ipgically related data referenced by a single name.

Eg. The collection of details of a student that may contain various data with different data types.

Eg.

struct student

{

int adm_no;

char name[40];

float weight;

};

OR

    Structure    Array
1. It is a user defined data typePredefined data type
2. It is a collection of different types of logically related data under one name.Collection of data elements of same data type having a common name.
3. Elements referenced using dot operator(.)Elements reference using its subscripts (position value)
4. When an element of a structure becomes another structure nested structure and complex structures are formed.When an element of another becomes another array, multidimensional arrays are formed.
5. Structure contains array as its elementsArray of structure can be formed.


Discussion

No Comment Found