1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Pascal Quiz 15

Discussion in 'Mac Programming' started by larswik, May 1, 2011.

  1. macrumors 65816

    Please DON'T give me the answer on this problem but help me understand the question better. It is a take home quiz due tomorrow.

    I don't know what a 'subscript' is that it refers to in this T or F Question.

    Q: " An Array is a collection of elements of the same type referenced by a single name and one or more SUBSCRIPTS. The SUBSCRIPTS may be of different types as long as they are ordered. True or False"


  2. macrumors 65816


    A subscript is the index you use to access the element of an array. In the C expression array, i is the subscript. In the C expression multidim[j], i and j are the subscripts. The term comes from mathematical matrices.
  3. macrumors 65816

    Thanks for that. The teacher likes to toss in trick questions and I almost want to say this question is TRUE except for the part that says "Subscripts may be of different types as long as they are ordered." Even if Subscripts are of a different type that is not going to effect the array type. If they are ordered the array will still be initialized, right?

    That is not giving away the answer, but I am leaning towards True as the result for the answer for the question.
  4. macrumors 68000


    What different types can a subscript be? For example, when I was learning BASIC (we use stone knives and bearskins in those days), and expression like "A(X)", where A was the array and X was the index, was verbalized as "A sub X". X was the subscript.
  5. macrumors 65816


    Sorry, I might have a caused a slight confusion by giving you examples of element access. The term applies equally (or more so in regards to you teacher's question) to how an array is declared.

    In the Pascal examples from your Pascal Multi-Dimensional Arrays thread, consider the following Pascal declarations.
    	suit : array[1..4] of char;
    	rank : array[1..13] of char;
    	cards : array[1..4,1..13] of char;
    In these declarations the stuff in square brackets can also be referred to as subscripts.

    I think your teacher is asking you to think about the data types of these subscripts, particularly in regards to multi-dimensional arrays like the cards array above.

    (BTW I actually don't know the answer to this question, because it's Pascal specific, I've forgotten 99% of Pascal.)
  6. macrumors 65816

    OK Guys and Gals, thanks again for the help. I will let you know tomorrow if I got it right or not.


Share This Page