Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 2, 2011, 01:09 AM   #1
larswik
macrumors 65816
 
Join Date: Sep 2006
Pascal Quiz 15

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"

Thanks,

-Lars
larswik is offline   0 Reply With Quote
Old May 2, 2011, 01:30 AM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
A subscript is the index you use to access the element of an array. In the C expression array[i], i is the subscript. In the C expression multidim[i][j], i and j are the subscripts. The term comes from mathematical matrices.
jiminaus is offline   0 Reply With Quote
Old May 2, 2011, 01:49 AM   #3
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
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.
larswik is offline   0 Reply With Quote
Old May 2, 2011, 02:16 AM   #4
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
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.
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote
Old May 2, 2011, 02:24 AM   #5
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
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.
Code:
var
	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.)
jiminaus is offline   0 Reply With Quote
Old May 2, 2011, 02:29 AM   #6
larswik
Thread Starter
macrumors 65816
 
Join Date: Sep 2006
OK Guys and Gals, thanks again for the help. I will let you know tomorrow if I got it right or not.

-Lars
larswik is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
pascal programming green.apple Mac Programming 18 Feb 26, 2013 11:21 PM

Forum Jump

All times are GMT -5. The time now is 12:56 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC