Skip to main content

Arrays: A Look At

 An array is an ordered collection of elements. Each element of the array is assigned a value. An array element can be considered as a variable. All the elements of the array are indexed. Zero and whole numbers are used as indices. Indexing of the array elements is purposeful. It helps to identify the array elements uniquely.

An array-name is associated with each array. The array-name once tagged, comes to be associated with each array element. In other words, the array-name becomes part and parcel of the identity of all the array elements.

In such a scenario, when the same array-name  applies to each array element, the unique index of each element gives the required uniqueness. This uniqueness is acquired by each and every array element. In this way identification of the array elements is helped. In order words, uniqueness is  bestowed  upon  the array elements with the help of indices.

Distinctiveness of array elements helps in data processing. We are able to specify the required array element very easily. Data processing techniques can be suitably chosen and we can get the output of array processing.

We can form an array of four integer values. Let us say, we are given four integer values: 4, 5, 9, 7. We can form an array out of the four values. This can be performed as:

///////////////////////////////////////////////////////////

int x[4]; //declaration of 4 element array

//int denotes Integer

//x denotes array-name

//'4' signifies indices: 0, 1, 2, 3

x[0] = 4; //1st array element

x[1] = 5; //2nd array element

x[2] = 9; //3rd array element

x[3] = 7; //4th array element

////////////////////////////////////////////////////////////

Association of Data Type with the  array elements is performed firstly. Such association leads to formation of an array. The formed array can hold values, as indicated by the Data Type. 

Let us suppose that an  array is related to a Data Type, say, Integer ( int ). So, all the array elements can only hold only integers. 

We can note that the index of the first array is '0'. The index of the fourth array element  ( last element ) is '3'. The four array indices are: 0, 1, 2, 3. The presented indices are in sequence. The value held by the second array element, denoted by 'x[1]' is '5'. Similarly, the value held by the last array element, denoted by 'x[3]' is: '7'.

Acquisition of a value that is other than integer by an array element is a serious mistake. It is indicated as an error. We must exercise caution in this respect. We must not assign a value to an array element that is not in agreement with the type of Data associated with the array.

_______________________

_______________________

Goodbye!

Have a great day!!

_______________________

_______________________














Comments

Popular posts from this blog

Local-Area Networks

Local-Area Networks ( LANs ) are restricted to a small area. Such Networks may be established within a building. Computers that are part of Local-Area Networks are Personal Computers ( PCs ) or microcomputers. These Computers are connected to each other. Simple communication lines connect these Pers Networks bring people together. When people join  hands teamwork becomes possible. The structural composition of LANs simplifies teamwork. In other words, LAN hardware supports teams having similar processing requirements. LAN Computers readily support personalization of tasks allocated to professionals.  Office staff can work together and share information. This improves the efficiency of the entire workforce. It has been noted that here all the Networked Computers are Personal Computers. They are of equal capacity. Mostly LAN users have similar tasks. If situations allow, a user is independent to access any Computer to serve his purpose. LAN users can exercise the option of secu...

Computers - An Introduction

Computers are man made machines. They are made to work very fast. Working fast they can solve  big and small problems.  Modern science has given us these computers. They are very popular. Computers affect and change lives. They keep us happy.The happiness grows. Computers are quick and smart. Great problem solvers and simplifiers are our computers. They can do our work without stopping. Focus is on doing only what is needed. Not needed, not done.  Computers are  life-less servants. They cannot think or make decisions on their own. They are empowered to work. They are given each and every thing so that they carry out our orders. Orders are respected by computers. The manner in which computers work is wholly dependent on man.  The quality of service provided by computers is remarkable. They are loved by human beings. Computers are known for smart and quick service. Computers do not give wrong results. Correct answers are always given. Questions which are difficult...

Euclid's Algorithm

The Greatest Common Divisor ( GCD ) of  two numbers is a number. The number ( GCD ) causes division of the two numbers. This number ( GCD ) is the greatest number that is possible. This divisor partially forms the two numbers. Adding  the divisor successively may result in formation of the two numbers. One can note that when the divisor is the greatest, the division of the dividend is the sharpest. The division operation is very effective. When the Greatest Common Divisor of two numbers is considered, we think of a number that can cause division of both the numbers. Here the two numbers are unequal. The Greatest Common Divisor causes divisions of the two numbers differently. This is clear from the two different quotient values.  The GCD value is very interesting to note. It relates very well with the two numbers. The GCD of two even numbers is also an even number. The GCD of two odd numbers is an odd number. So, we can say that GCD is an abstraction of the two numbers in ...