Breaking News
yeni film izle hd film seyret film izle

Introduction to Array

An array is a collection of same data type, whose individual elements are arranged in a regular pattern.
Practical description of the arrays.
So now we will show you how the array elements are stored in memory
A(0) A(1) A(2) A(3) A(4) A(5) A(6) A(7)
2 8 3 6 1 4 7 5
First of all we will discuss about some components which always comes in arrays.
These are:
The number of elements in each dimension is called extent in that dimension
The number of dimensions of an array is called its rank.
The size of an array is the total number of elements in it.
The shape of an array is a vector whose elements are the extent of the array in each of its dimensions.
Why we need array?
· It is easier to declare one variable name instead of tens or even thousands variable name   or Arrays are the only way which can store and manipulate the thousands and thousands   of data of same type.
· Flexible accessing (one can easily operate on various array areas in different ways).
· Easier to understand the code (notational convenience).
· Inherent Data Parallelism (perform a similar computation on many data objects   simultaneously).
· Optimization opportunities (for compiler designers).
· Reduction of program size.
How the Arrays are created?
As we know that variables in Fortran may be integer, real, logical or complex, Array name is defined in the same way.
Let us consider if X is declared as an array name and if it will be real and their elements X1, X2,…..must have real values. Similarly again consider if MATR is an array name, then the array will be integer and its elements will be integers. Arrays of integer, real, logical or complex types may be formed by declaring the types of variables in explicit type declarations.
Array can be understood by the following example:
Let us consider in a class there are 100 students and the marks obtained by the each student in the exam are written on one or more lines. A program is required to print out the highest and the second highest marks obtained in that exam. It is a time taking process when is solved by simple mathematics. With the help of Array it can be solved in very short period.
In this program the statement DIMENSION MARKS (10) is non-executable statement which provides information to the compiler that MARKS is a subscripted variable with 10 components and each component is of type integer since MARKS is an integer variable name.
The DO loop:
DO 10 I = 1, 10
Here the DO loop reads 10 data. The first number read is assigned to MARKS (1), the second number is to MARKS (2) and so on. The DO loop with terminal statement 25 picks the highest component of MARKS and stores in the first. In the next DO loop all the components of marks equal to FIRST are skipped and the highest component picked from among the rest and assigned to SECOND.
The DIMENSION statement gives the information that MARKS has 10 components for which values are to be assigned.
some basic rules are necessary for array operations.
A step by step procedure is:
· Declare arrays, and set storage using a type declaration statement.
· If the arrays are allocatable, allocate them.
· Fill the arrays with numbers.