IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

array indexing


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Sat Jul 24, 2021 10:27 pm
Reply with quote

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
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Sat Jul 24, 2021 11:23 pm
Reply with quote

None of them when you compile with the default compiler options.

RTFM!
Back to top
View user's profile Send private message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Sun Jul 25, 2021 7:42 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2022
Location: USA

PostPosted: Mon Jul 26, 2021 6:51 am
Reply with quote

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 36_8_9.gif 12.gif 36_11_6.gif


Do we need to pass again the primary school study at this forum???
Back to top
View user's profile Send private message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Tue Jul 27, 2021 3:30 am
Reply with quote

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 36_8_9.gif 12.gif 36_11_6.gif


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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts How to move values from single dimens... COBOL Programming 1
No new posts COBOL batch program using large size ... COBOL Programming 3
No new posts COBOL - Array result in single variab... COBOL Programming 3
Search our Forums:

Back to Top