What will happen if a variable is declared as below..
Explain with an example? Working storage section:-

01 WS-VARX PIC X(10) VALUE 'ABCDEFGHIJ'.
01 WS-VARN REDEFINES WS-VARX PIC 9(5) VALUE '12345'.

What will happen I am going to Display the WS-VARX and WS-
VARN?

Answers were Sorted based on User's Feedback



What will happen if a variable is declared as below.. Explain with an example? Working storage sec..

Answer / mallikarjun

WE CANNOT GIVE VALUE CLAUSE IN THE SECOND STATEMENT I.E.
WS-VARN REDEFINES WS-VARX PIC 9(5) VALUE '12345' . IF YOU
SPECIFY VALUE CLAUSE SYSTEM WILL SHOW AN ERROR, IF YOU
SPECIFY WITH OUT VALUE CLAUSE I.E.
WS-VARN REDEFINES WS-VARX PIC 9(5).
THEN IF YOU GIVE DISPLAY STATEMENT THEN ABCDEFGHIJ AND
ABCDE WILL BE DISPLAYED

Is This Answer Correct ?    26 Yes 3 No

What will happen if a variable is declared as below.. Explain with an example? Working storage sec..

Answer / mallikarjun

if you use redefines in your statement the numeric
declaration will be over rided and stored as charechter, i
have testing this practically

Is This Answer Correct ?    6 Yes 0 No

What will happen if a variable is declared as below.. Explain with an example? Working storage sec..

Answer / sandy

Mallikarjun is 100% correct

Is This Answer Correct ?    5 Yes 2 No

What will happen if a variable is declared as below.. Explain with an example? Working storage sec..

Answer / neela

Hi KHB Naidhu,
pic x means it should be alphanumeric
pic 9 means it should be Numeric

so we have to move numeric values also to the pic x

for this qtion is correct what was explained my
mallikarjuna.

regards
Neela

Is This Answer Correct ?    2 Yes 1 No

What will happen if a variable is declared as below.. Explain with an example? Working storage sec..

Answer / khbnaidu

Mallikarjun Ur answer is wrong because of WS-VARN is Numric
field & how will display the ABCDE result?

Is This Answer Correct ?    2 Yes 13 No

What will happen if a variable is declared as below.. Explain with an example? Working storage sec..

Answer / siva

WS-VARX = 12345FGHIJ
WS-VARN = 12345

Is This Answer Correct ?    1 Yes 14 No

Post New Answer

More COBOL Interview Questions

how to code in cobol while using variable block file?

1 Answers  


consider the following FD FILE-1 01 REC-1 PIC X(80) ...... WORKING-STORAGE SECTION 01 W-REC PIC X(90) ........ PROCEDURE DIVISION FIRST-PARA ....... READ FILE-1 INTO W-REC AT END MOVE 1 TO EOF-FLAG which of the following is true with respect to the above? a.REC-1 will contain nothing and W-REC will contain the contains of the record read b.REC-1 and W-REC contain the same data c.syntex is invalid and error will occur d.REC-1 and W-REC must be of same size

1 Answers   TCS,


What will happen if we generate GDG (+2) version without generating (+1) version?

2 Answers   IBM, T systems,


What is Static and Dynamic linking ?

3 Answers  


How we copy a program from production region to development region.What is the process & syntax ?

3 Answers   CTS,






How To Separate The Numerics From An Alphanumric Data Item Which Contains Both Alphabates And Numerics ?

4 Answers  


What R 2 of the common forms of the EVALUATE STATEMENT ?

1 Answers   Cap Gemini,


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

0 Answers  


What will happen if you code GO BACK instead of STOP RUN in a stand alone COBOL program ?

8 Answers   Arigo Infotech, IBM,


how do u list the abended jobs?

1 Answers   IBM,


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

0 Answers  


The below is the declaration for a variable ws 01 ws pic 9(3). if you want to insert space how will you do that. in which level u should do it

3 Answers   ADP,


Categories