Question

Data types and structures Pascal allows the use of enumerated types as index types. For example,...

Data types and structures

Pascal allows the use of enumerated types as index types. For example, if we define the enumerated type GreatLakes to have the values Erie, Ontario, Huron, Michigan, and Superior (ordered here by increasing volume of water), then we can define:

type GreatLakes = (Erie, Ontario, Huron, Michigan, Superior);

area: array [ GreatLakes ] of integer,

elevation: array [ GreatLakes ] of real;

and give them values

area := ( 9910, 7340, 23000, 22300, 31700 );

elevation := ( 570.38, 244.77, 578.68, 578.68, 600.38 );

Now we can access individual elements to find, for example, that

area[Erie] = 9910

area[Superior] = 31700

elevation[Huron] = elevation[Michigan] = 576.68

In the above definitions we stored the areas and elevations of the Great Lakes in vectors (1- dimensional arrays). Restate these definitions in order to store the same information in a structure that is:

(a) A vector of records

For defining records, use the syntax:

Person: record

age: integer;

sex: (Male, Female); height, weight: real; married: Boolean

end;

(b) A record of vectors

(c) A 2-dimensional array indexed by type GreatLakes and by another enumerated type.

Please Give me answers for a) b) c)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
a.)
var
Person : record
   age: integer;
   sex: char;
   height,weight: real;
   married: Boolean;
end;

c.)

type
  more_complex_array = array [GreatLakes..int,1..3] of extended;
 
var
  specialmatrix: more_complex_array;
Add a comment
Know the answer?
Add Answer to:
Data types and structures Pascal allows the use of enumerated types as index types. For example,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Many college students study by simply repeating their notes over and over (rote rehearsal). Although this...

    Many college students study by simply repeating their notes over and over (rote rehearsal). Although this method is good for processing data into STM there are other means to effectively move material into LTM. Please read the “How To Study Effectively” section in Chapter 8. Now, in one to two paragraphs discuss how you currently prepare for exams and how you might incorporate additional techniques to your studying behavior. Make sure that you include four strategies from the text. Based...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT