Skip to main content

What is an array ? What are the differences between an array and a structure ?



Answer:

Array:
An Array is a collection of the homogeneous (same type) elements stored under unique name. The elements are stored in the contiguous memory locations. The values in an array is called as ‘elements of an array’. These elements are accessed by numbers called as ‘subscripts or index numbers’. Arrays may be of any variable type. Array is also called as ‘subscripted variable’.


Differences between an array and  structure:
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
(i)An array is a collection of related data elements of same type.
(i)Structure can have elements of different  types
(ii)An array is a derived data type
(ii)A structure is a programmer-defined data type
(iii)Any array behaves like a built-in data types. All we have to do is to declare an array variable and use it.
(iii)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.


Popular posts from this blog

Draw the basic organization of computer

Answer:                 The basic organization of computer__ Input Unit: ·          It accepts (or reads) instructions and data from outside. ·          It converts these instructions and data in computer acceptable form ·          It supplies the converted instructions and data to the computer system for further processing. Central Processing Unit (CPU): Control Unit: Control unit of a computer system manages and coordinates the operations of all other components of the computer system. Arithmetic Logic Unit(ALU): Arithmetic logic unit of a computer system is the place, where the actual executions of instruction, takes place during processing operation. Storage Unit: Primary Memory: It is volatile ( loses data on power ...

Describe the four basic data types. How could we extend the range of values they represent?

Answer: The basic four data types are: Data Type Integer Type Character Type Floating Point Type Void Type signed int short int long int unsigned unsigned int unsigned short int unsigned long int char signed char unsigned char float double long double