Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Difference between Index and Subscript

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Difference between Index and Subscript
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    Post subject:
Reply with quote

hi arunoday
check this link
http://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    Post subject:
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    Post subject: Re: Difference between Index and Subscript
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us