Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In need of help with parallel arrays
#1
Hey Everyone!

I'll start by saying that I'm NOT looking for help on a homework assignment. I'm taking a class that basically teaches the logic behind programming. It doesn't teach a specific language, but we use QBASIC to write beginning programs. I understand how to write pseudocode with parallel arrays. However, I don't know how to properly format them for QBASIC. I was just wondering if someone would respond to this message with a couple of parallel arrays and a brief explanation about the individual components.

Have a wonderful day!

~Bridgette~
Live, Love, Laugh
Reply
#2
What is a parallel array? Do you mean a string array for a name and a integer array for the age or something like that?

Let's go with that....

DIM Names(100)
DIM Ages(100)

So now you have two arrays that can hold 100 names and ages.

Now all you have to do is fill the array element values in the program.

1) Get the data from a user entry
2) Get data from the program using DATA field
3) Get data from a file

The array elements should match the data supplied.

So If I enter "Ted" for the name and 50 for my age, then :

PRINT Names(1) ' displays Ted

PRINT Ages(1) ' displays 50

You can create other arrays for different number types.
Get my QB demonstrator here: http://dl.dropbox.com/u/8440706/Q-Basics.zip
Reply
#3
Hi Clippy!

Thanks for responding to my post! According to my textbook, parallel arrays refer to two corresponding arrays where each element in one array is associated with the element in the same relative position in the other array. Your example definitely fits as a parallel array. I was confused about how an association was made between the two elements in different arrays. Now, I can see its the number in the () that forms the association. I'm learning slowly, but surely ... I greatly appreciate your help!

Have a blessed day!

~Bridgette~
Live, Love, Laugh
Reply
#4
OOPS I forgot to define the Array types:

DIM Names(100) AS STRING
DIM Ages(100) AS INTEGER
Get my QB demonstrator here: http://dl.dropbox.com/u/8440706/Q-Basics.zip
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)