Without using move verb how to move one variable to another.

Answers were Sorted based on User's Feedback



Without using move verb how to move one variable to another...

Answer / sudha

01 A PIC 9.
01 B PIC 9.

Compute A = B.

Is This Answer Correct ?    25 Yes 2 No

Without using move verb how to move one variable to another...

Answer / bala

We can do this in multiple ways.
1) Using UNSTRING
2) COMPUTE
3) Also, REFERENCE MODIFICATION i.e, if XYZ is a variable with value 'all interview' then
A = XYZ(1:3) moves the first 3 characters of XYZ variable to A.
i.e, A value will be 'all'

Is This Answer Correct ?    8 Yes 2 No

Without using move verb how to move one variable to another...

Answer / monick

SET A TO B

Is This Answer Correct ?    11 Yes 6 No

Without using move verb how to move one variable to another...

Answer / manikandesvaran

1)Using REDEFINES you can acheive this.

For ex.
10 WS-OLD-START-DATE PIC 9(8).

10 WS-NEW-START-DATE REDEFINES WS-OLD-START-DATE.
15 WS-START-YEAR PIC 9(4).
15 WS-START-MONTH PIC 9(2).
15 WS-START-DAY PIC 9(2).

Now WS-NEW-START-DATE will hold the value of WS-OLD-START-
DATE.

2)Using UNSTRING operator.

UNSTRING WS-NEW INTO WS-OLD

3)Using COMPUTE verb.

COMPUTE WS-NEW = WS-OLD.

4)Using SET statement.

SET OLD to NEW.

Is This Answer Correct ?    5 Yes 1 No

Without using move verb how to move one variable to another...

Answer / raju

Let the variables and their values be A = 20 and B = 30
and we need to swap them as A = 30 and B = 20 without MOVE statement
BEFORE AFTER
A B A B
Way 1: COMPUTE A = A+B 20 30 50 30
COMPUTE B = A-B 50 30 50 20
COMPUTE A = A-B 50 20 30 20

Way 2: COMPUTE A = A*B 20 30 600 30
COMPUTE B = A/B 600 30 600 20
COMPUTE A = A/B 600 20 30 20

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More COBOL Interview Questions

What is mean by maxcc

7 Answers   Syntel,


What is the difference between performing a SECTION and a PARAGRAPH?

5 Answers   Accenture, Patni,


What is the LINKAGE SECTION used in COBOL?

0 Answers   UGC Corporation,


What are the steps you go through while creating a COBOL program executable?

3 Answers  


I hav vari declaration like..... 77 a pic s9(9).99. 77 b pic s9(9).99 comp. 77 c pic s9(9).99 comp-3. if i use MOVE 123456789.99 to a,b,c what happen every one working fine ?

1 Answers   Mphasis,






Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?

3 Answers   Microsoft,


What is SQL Code -904 and -903 in DB2 And how to handle it?

1 Answers   IBM,


write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc

0 Answers  


if you give cylinder(1,1)how many cylinders it will be allocate?

3 Answers   Hewitt,


1.What is the limit of linkage section?

4 Answers  


Can the OCCURS clause be at the 01 level?

8 Answers   Oracle,


how can we get current dat and time thru cobol pgm

3 Answers   DELL,


Categories