View previous topic :: View next topic
|
Author |
Message |
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
The following array is declared for TAB:
DCL TAB (4,0:3,-4:-1) CHAR (01);
Which of the following statements will result in an indexing error?
- A = TAB (1,0,1)
- A = TAB (-1,0,1)
- A = TAB (0,0,0)
- A = TAB (3,3,3)
- A = TAB (3,3,-3)
- A = TAB (0,-1,-3)
- A = TAB (2,1,-2) |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
None of them when you compile with the default compiler options.
RTFM! |
|
Back to top |
|
|
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
prino wrote: |
None of them when you compile with the default compiler options.
RTFM! |
Thank you very much.
if you have the time, can you please explainme how the indexing works.
what i know and learnt is:
DCL TAB (4,0:3,-4:-1) CHAR (01);
this is 3 dim array with lower and upper buonds specified with 1 element of char(01). Thank you sergeyken for explaning this. so the total number of instances will be 4+4+4 = 12. is this correct?
but what does the indexing mean ?
what i think is since the all indexing is within 4 (whichis the max no. of instances) they all point to some data, but if i say TAB(5,0,1= then it is an error? am i correct? please help. THAKN YOU |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2136 Location: USA
|
|
|
|
grasshopper wrote: |
what i know and learnt is:
DCL TAB (4,0:3,-4:-1) CHAR (01);
this is 3 dim array with lower and upper buonds specified with 1 element of char(01). Thank you sergeyken for explaning this. so the total number of instances will be 4+4+4 = 12. is this correct? |
OMG!!
This is 3-dimensional array; its total number of elements is 4*4*4=64 items!!!!!!!!!
As a primitive example, consider a cube with each dimension equal to 4 units. The volume of this cube is not 4+4+4, but 4*4*4=64 cubic units!!!
At my school, we learned this during our first 4 years (at the age not older than 11 years).
This topic resembles me the clip available from YouTube: “ALTERNATIVE MATH”
It proves that 2+2=22
Do we need to pass again the primary school study at this forum??? |
|
Back to top |
|
|
grasshopper
New User
Joined: 22 Jul 2021 Posts: 12 Location: germany
|
|
|
|
sergeyken wrote: |
grasshopper wrote: |
what i know and learnt is:
DCL TAB (4,0:3,-4:-1) CHAR (01);
this is 3 dim array with lower and upper buonds specified with 1 element of char(01). Thank you sergeyken for explaning this. so the total number of instances will be 4+4+4 = 12. is this correct? |
OMG!!
This is 3-dimensional array; its total number of elements is 4*4*4=64 items!!!!!!!!!
As a primitive example, consider a cube with each dimension equal to 4 units. The volume of this cube is not 4+4+4, but 4*4*4=64 cubic units!!!
At my school, we learned this during our first 4 years (at the age not older than 11 years).
This topic resembles me the clip available from YouTube: “ALTERNATIVE MATH”
It proves that 2+2=22
Do we need to pass again the primary school study at this forum??? |
yes, i agree.
64 instances.
so why is every indexing correct because it does not exceed the range? what is the right explanation? |
|
Back to top |
|
|
|