What is the difference between index and subscript?

Answers were Sorted based on User's Feedback



What is the difference between index and subscript?..

Answer / jkb

Index represents the displacement value of the table entry
from the beginning of the table whereas subscript is the
occurrence number of the table entry.

To calculate the displacement of the table entry from its
beginning when subscript is used takes 16 additional
instructions from the system because of that the usage of
the index is more efficient.

An index can only be modified using PERFORM, SEARCH & SET.
Need to have index for a table in order to use SEARCH,
SEARCH ALL.

Is This Answer Correct ?    25 Yes 3 No

What is the difference between index and subscript?..

Answer / harish

subscript normal variable dec in w-s section.
index cant

subscript can be accepted or displayed
for index set index up by value down by value..

subscript- arithmetic operation is possible..


subscript refers to array occurance,
index refers to the displacement of start of the array



pls correct me if anything wrong

HARISH POOMGAME SHIVAPPA(hassan,karnataka)
NIIT TECHNOLOGY
KOLKATA

Is This Answer Correct ?    17 Yes 5 No

What is the difference between index and subscript?..

Answer / vamsi krishna g

subscript is occurence type like arrays so if u want to
dispaly a value of it means it will search for it from
begining

indexed:
if u want to dispaly a value of an vairable it will
directly diplaces to that value and display the value

so from this we can say
subscript is an occurance type and indexed is displacement
type
if any wrong means please update me

Is This Answer Correct ?    12 Yes 2 No

What is the difference between index and subscript?..

Answer / manjunath

ubscript - Subscript is used to access elements in array.
Index also used for the same purpose.


Ex. 01 WS-GROUP.
05 WS-MONTH PIC X(3) OCCURS 12 TIMES.

To access 2nd month we sepcify WS-MONTH(2).
Value enclosed in brackets is called subscript ( in this case 2 ).


You can use INDEX for the same.

Ex. 01 WS-GROUP.
05 WS-MONTH PIC X(3) OCCURS 12 TIMES INDEXED BY WS-INDX.

In above example WS-INDX is a INDEX data item.
we can use this variable to access the elements in the array.

If you want to access 2nd element in the array. need to write the code as follows

SET WS-INDX TO 2.
DISPLAY " 2nd element in array " , WS-INDX.

An index is similar to a subscript, but internal value in the variables are different..
Normaly subscript refer the occurance number of the item in array. in our example that is 2. means to refer second occurance we use number 2.

In case of index, to refer second element of your array, it shoud contains value of displacement from the starting of the arrary. i.e, in our example we used SET command to set value in index field WS-INDX. after execution of this command
WS-INDX contain the value 3. To refer third element it should contains the value of
6, for fourth element it should contain the value of 9 ( in our example array element size is 3 ).

Is This Answer Correct ?    1 Yes 0 No

What is the difference between index and subscript?..

Answer / maveric

can anyone give some example on this please?

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More COBOL Interview Questions

I have the requirement to compare the two files and pick up the matching records. File 1. file2 23 32 32 13 34 15 35 36 36 35 43 Get the matching records from this 2 files to out file. how you will do this in cobol program?

15 Answers   ADP, Broadridge, CTS, HSBC, L&T, RBS, TCS,


What was removed from COBOL in the COBOL II implementation?

0 Answers  


how can i see junk values in dclgen or in hostvariable of comp ?

0 Answers   DELL,


How to find How Many Lines in Sysin DD * Parameter Thru Cobol Coding? If any one knows the Answer Please Reply .....Thanks From Shree

3 Answers   Merrill Lynch,


I have program P1 which calls file F1 which has 100 records and following structure 001 .................. 002 .................. 003 .................. 098 .................... 099 ................... 100 .................... Now I want to read these files and write these records in file F2 in following manner. 001 ...... 051 ..... 002 ...... 052 ..... 003 ...... 053 ..... .......... ....... .......... ....... .......... ....... 048 ........ 098 ...... 049 .......... 099 ....... 050 .... 100 ......

4 Answers   Accenture,






copy 100 records without using ibm utilities

3 Answers  


IF there 5 to 6 files in a JCL and there is some space abends, how can we identify which file has space abend and what can be done to get off that abend or rectify that abend.

2 Answers   ADNA, CSC,


what are the limitations of Inline Perform?

3 Answers   Zensar,


What is an in-line perform ?

4 Answers   Accenture,


1.Is it possible to move the data from 99.99 to 99v99? 2.What is the CICS-vsam Compilation process? 3.In My GDG 5 generation will be there GDG3 got an abend what will happen? 4.In my GDG first generation is +1 And I want to add the new generation what will happen previous generation? 5.How can you give the PIC clause below conditions A). s9 (reddy), B). s9 (5) occurs 5 times? 6.How override the proc from a particular step? and what is symbolic and override Procs?

0 Answers   IBM,


What is the maximum size of a 01 level item in COBOL I? in COBOL II?

2 Answers   IBM, RBS,


Wat is the difference between NEXT and CONTINUE statement in cobol,can any one explain with example.

11 Answers   Deloitte,


Categories