Arrays - Module 4
1. Introduction
I wasn't too sure about making Arrays the forth module but I figured it is a very useful topic for every programming language so I'll get it out of the way.
There are many Data Types, until now I have only been using on my lessons simple data Types. Arrays belong to the Structured Data types.
When you are able to assign multiple values to a single variable, then this variable is considered Structured Data. Arrays are an ordered set of data all of the same type, each element is identified by an index and the array by a name. An array can also have multiple dimensions.
2. One Dimensional Array
These Arrays only have one index. All data types in pascal are declared in the same place. So before the actual program starts. Arrays can also be declared as types.
Syntax:
Var <array_name>: Array [1..12] of Integer;
Declaring a Data Type:
Type Data1 = Array[1..12] of Integer;
var x, y: Data1;
Example:
3.Multidimensional Array
Depending on how many dimensions the array has, the index number will vary.
Syntax:
Bidimensional Array
var Data1: Array [1..2,1..7] of Integer;
0 comentários
Posts a comment