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

Difference between Index and Subscript


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
arunoday

New User


Joined: 17 May 2005
Posts: 18
Location: Bangalore

PostPosted: Mon Jun 13, 2005 6:34 pm
Reply with quote

Hi

Can anyone tell me the exact differences between index of an Array and subscript of an Array ?

Thanks in advance

Arunoday
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Mon Jun 13, 2005 7:08 pm
Reply with quote

hi arunoday
check this link
www.ibmmainframes.com/viewtopic.php?t=2705
please search before posting, as this will give you only more information. Hope you take this in positive way.
Back to top
View user's profile Send private message
ravindra mudumby

New User


Joined: 16 Jun 2005
Posts: 6
Location: blore

PostPosted: Sat Jun 18, 2005 12:44 am
Reply with quote

An array is a collection of data items, called array elements, of the same type, and stored in adjacent memory cells. All data in an array is associated with a symbolic name.

As other data types, an array needs to be declared before it can be used.

The declaration "double x[8];" instructs the compiler to associate eight memory cells, each can hold a double value, with the name x.

Variables in an array are not named individually, but though the array name and an index, or subscript, value, which is a serial number starting at 0. For example, the subscripted variable x[0] (read as x sub zero) may be used to refer to the first element in the array x, x[1] the next one, and so on. In C, if an array is declared to contain n elements, the range of valid index values is from 0 to n-1. For example, FIGURE 8.1:

After declaration, each element in the above array can be used as a normal double value.

An array can be initialized in the same statement as it is declared, such as

int squares[] = {0, 1, 4, 9};

Please note that in this kind of declaration the size of the array is implied by the number of the initial values. Also, this format can only be used in initialization, but not in any assignment after it.


2. Array subscripts
It is important to understand the relation and difference between a subscript of an array and the associated value stored in the corresponding memory cell.

A subscript can either be a constant integer, or a variable or expression that has an integer value.
Back to top
View user's profile Send private message
arunoday

New User


Joined: 17 May 2005
Posts: 18
Location: Bangalore

PostPosted: Mon Jun 20, 2005 6:01 pm
Reply with quote

Thanks Ravindra for your explanation. Really helpful !!!!
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Cobol file using index COBOL Programming 2
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts DL/I status code AK for GU call using... IMS DB/DC 1
Search our Forums:

Back to Top