How do u initialize an array?

Answers were Sorted based on User's Feedback



How do u initialize an array?..

Answer / snehatechm

array can be initiazed by INITIALIZE verb or by moving the
values to the elements of a table.
if u initialise an array with INITIALIZE verb your
alphanumeric fields will be stored with space and numeric
fields with '0'.

Is This Answer Correct ?    9 Yes 3 No

How do u initialize an array?..

Answer / nagaraj

You can initialize an array in several ways based on the
values in the array.

If you know the values in the array already, then you can
do it through REDEFINE clause. I will give an example here.

05 MONTHS-VAL PIC X(36)
VALUE 'JanFebMarAprMayJunJulAugSepOctNovDec'.
05 MONTHS REDEFINE MONTHS-VAL PIC X(3)OCCURS 12 TIMES.

If you want to initialize at run time based on the user
input, then you can pass the values via ACCEPT statement
(online) /SYSIN DD statement (batch) and initialize the
COBOL array.

If you want to initialize with default values then you can
do it using INITIALIZE verb but be careful doing so.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More COBOL Interview Questions

how would you resolve sb37 and SE37?

2 Answers   Hewitt,


Explain the configuration section of a cobol program with examples of syntax.

0 Answers  


what are decleratives in cobol?

0 Answers   GGG, Satyam,


in the TIME parameter we r giving hours r minutes

4 Answers   IBM,


What is level 66 used for ?

3 Answers   TCS,






can we declare occurs in 01 level?

2 Answers   Temenos,


We are using the searching a table which is indexed, once the key is found, how can we get the occurance at which the key was found.

1 Answers  


I encountered an error when I move spaces to a numeric field?What should I do to move spaces on that field?help please.

9 Answers  


How to Pass table from a cobol program to another cobol program and how to use that table in called program

8 Answers   Patni, SunGard,


How to read a record from bottom of a file which is indexed by 'A'.

4 Answers   Oracle,


I have a PS file and I would like to manually insert the binary values (like a COMP format) into the file. How can i do that? the way do in COMP-3 format.. suppose i want to insert -12345 in to file in comp-3 format. simply we can open a file in edit mode and do HEX-ON and insert the value . SEE BELOW-- 135 24D in 3 bytes - this will be COMP-3 presenatation of -12345.

1 Answers  


What is the usage of comp fields in cobol?

0 Answers  


Categories