wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

Arrays In A Structured Data Object

 

What we all learn in class:

This is a brief section of what should be learned in class just as an overview so that everyone starts on the same page.

Arrays are:





 

bulleta fixed number
bulletcontiguous
bulletsame data type

Structs eliminate this last restriction

Structs:

bulletconsist of 2 or more component data types
bulletmay be simple and common for example
bulletint
bulletchar
bulletfloat
bulletunsigned int
bulletlong
bulletdouble
bulletshort
bullet... etc.
bulletmay be a pointer type
bullet*int
bullet*char
bullet*float
bullet*unsigned int
bullet*long
bullet*double
bullet*short
bullet*... etc.
bulletor another structured object in itself.

 

Don't get me wrong it is fascinating but after a while it does get tedious unless we stop and think of how this will be used and is this really used.

 

 

 

So how can this all be used and is it being used?

Let's consider what an array with no limits on data type could be used for.

Well...

Everything as long as your dealing with information.

For example just you yourself are arrays of structure

how so?

well ...:

bullet

Name (char)

bullet

Birth date (string for example October 25, 2004 or 10/25/04 or ...)

bullet

age (int, or float if you want partial years)

bullet

height (float)

bullet

weight (float)

bullet

sex (string)

bullet

address (string)

bullet

phone number (array)

bullet

and on and on and on.

So where would this be used:

bulletMedical records
bulletDriving license
bulletWork
bulletHousehold bills
bulletand the big one CREDIT CARDS
bulletand on and on and on.

Ok they could be used this way but are they?

With out a doubt!

Consider this example:

You get an advertisement in the mail about getting a credit card with 9% apr. and for whatever reason you decide to fill it out and mail in for the new card.

you would fill out a sheet similar to the following:

 

  





Name:  Adam

Co Applicant:  Eve

Date: 1/1/1
 

SS Number:  111-11-1111

SS Number:  222-22-2222

Phone Number: 777-7777
 

Work: Gardener in Eden

Monthly Income: 4 stones (1 stone  = $150)

Address: 100 South Paradise
 

Years at Work: 7

Addition Income: 3 stones

 
 

Signature:   Άמצش

Co App. Signature:  Έڛۇ

 
 

 
 

 

The credit company would process the application and send you the card and that would be it, right?

Wrong!!!!

 

They would set up an array of structure maybe like the following:

#include<stdio.h>

#include<string.h>

struct application

{

char Name[20];

char co_app_name [20];

int unsigned ssn;

int unsigned co_app_ssn;

int unsigned phone;

char adress [20];

float total_income_annual;

float credit;

};

int main()

{struct application applicant[1] =

{{"Adam","Eve",111111111,222222222,7777777,"100 South Paradise",12600,5000}};

printf("Name = %s, CO App = %s, SSN = %lu, CO SSN = %lu\nPhone = %lu, Address = %s, Income = %8.2f\nCredit Limit = %7.2f\n",applicant->Name,applicant->co_app_name,applicant->ssn,applicant->co_app_ssn,applicant->phone,applicant->adress,applicant->total_income_annual,applicant->credit);

}

Which would leave the following on their monitors if you were to ever call in for a credit inquiry or increase:

And with even more tweaking they could have a screen that gives available credit, credit score, how often payments are made, how much is normally paid, and many other tools that could mean the difference of more credit or canceling a card.

Now this is just one VERY simple use of an array of structure, the point is they are everywhere and weather we realize it or not our lives in many ways are effected by them, and the list above of how they are being used is just a couple there is feasibly thousands and thousands of ways they can be used.

Addition web sights:

the following sites have some good additional information

http://etnus.com/    In this site go to total view and c/c++ support

http://www.cs.buffalo.edu/faculty/bina/cs1/cs1/lec7/sld001.htm    This sight has a slide presentation (class lecture) on arrays.

www.cs.utexas.edu/users/rpriebe/cs302_032/Lectures/15-Java.ppt    This sight is a powerpoint slide presentation (class lecture) on arrays