mud14 - Lecture C14: Data structures - Arrays Response to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture C14: Data structures - Arrays Response to 'Muddiest Part of the Lecture Cards' (45 respondents) 1) Why on the "Initializing Arrays" slide did we use coord1, coord2, and coord3 in the example? (1 student) I introduced 3 new arrays all of type small_arrays defined on the previous slide. 2) How do you distinguish between column-major and row-major arrays (besides just knowing)? and similar questions (2 students) That is just it, it is as always up to you as a programmer to interpret the data stored in memory. There is now way we automatically can know how data is stored, without taking a look at the code storing the data in the array. 3) How are arrays used as Parameters? and similar questions (6 students) Take a look at 'sum_array.adb' distributed via email today. The example shows how a procedure can be written to add the elements of any array of integers. The RANGE attribute is used so that the loop control variable takes each index value in turn, no matter what the actual range of values is an unconstrained array type is used for the formal parameter, so that any array of integers can be supplied as the parameter, no matter what its size. 4) How do you display an entire array? (1 student) We have to print all the items one by one. For example, as shown in the lc_letter_freq.adb (shown in class and distributed via email) where all items of array 'Count' will be printed. for T in Lc_Letters loop Put(T); Put(Count(T), Width=>8); New_Line; end loop ; 5) Did not know what 16x8, 32x8, 7x8x8 were for? and similar questions (2 students) Just pointing out that 3 different arrays with same amout of items/position (all three arrays large enough to hold 8 items) will need different amout of bytes to be stored in the computer memory. Array 1: Typical Integer represented using 16bits, thus size of array = 16x8 bits Array 2: A floating point number can be represented using 32 bits, thus size of array = 32x8 bits Array 3: One character can be represented using 8 bits (ASCII value for character). Each string in the third array was larg enough to hold 7 characters, thus size of array = 7x8x8 bits 6) What are unconstarined arrays? and similar questions (3 students) unconstrained array types: element type is specified in type declaration index type is specified in type declaration range of index values (ie size) is not specified in type declaration specify range of index values in variable declarations...
View Full Document

This note was uploaded on 02/20/2012 for the course AERO 16.02 taught by Professor Charlescoleman during the Winter '12 term at MIT.

Page1 / 5

mud14 - Lecture C14: Data structures - Arrays Response to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online