b_book1.gif (162 bytes)Data - Structures

Array

Imagine that you have been given the following programming task:

Read an integer N , which will be at the most 25, then read a list of N numbers and print the numbers out in reverse order.

To solve the problem we need to set up an array that has n entries..

In C
main()
{
#define nums 25

int arr[nums],i;
.. code here ..
}

An array is a predetermined number of storage locations set aside to store a predetermined number of data items, the size is fixed at program compilation time.

Data can be stored and accessed by means of index values which keep track of the serial location of each data entry.

Data can be stored using:

May be:

In C (and Pascal) we define a string as an array of characters
(here msg[3] = "l")

main()
{
char msg[30];
strcpy (msg,"Hello, world\n");
puts(msg);
}

An array of one dimension with 4 entries in sequence by key

in Pascal:

type
client = record
            key: integer;
            LastName,FirstName: string[30];
          end;
var
  Clients : array[1..100] of client;

dadsar02.gif (3054 bytes)

In Pascal we could store integers in an 8 x 8 grid using
var checkerboard: array [1..8, 1..8] of Integer;

A two dimension array with 4 records (rows) and 5 fields (columns)

in Pascal:

type
grades = record
            key: integer;
            grade: array[1..4] of integer;
          end;
var
  Clients : array[1..100] of client;

So Clients[2].grade[1] = 70.

dadsar03.gif (3248 bytes)

w98cp.gif (23802 bytes)

 

Here
Level 1:  "File | Edit | View ..."
Level 2:  "Toolbars | Status Bar | ...."
Level 3: "by Name | by Type | ..."

So the "by Date" option could be
  Menu(3,10,4).

dba97_01.gif (45645 bytes)

MS-Access allows us to easily add or modify the menus as shown left;

[Rev 05/03/99] 2/6/97 © 1997-99 V/2-Com (Verhaart), P O Box 8415, Havelock North, New Zealand.