Tuesday 12 February 2013

Difference between Arrays and Structures in C

Both the arrays and structures are classified as structured data types as they provide a mechanism that enable us to access and manipulate data in a relatively easy manner. But they differ in a number of ways listed in table below:
Arrays
Structures
1. An array is a collection of related data elements of same type. 1. Structure can have elements of different  types
2. An array is a derived data type 2. A structure is a programmer-defined data type
3. Any array behaves like a built-in data types. All we have to do is to declare an array variable and use it. 3. But in the case of structure, first we have to design and declare a data structure before the variable of that type are declared and used.

No comments:

Post a Comment

Comment