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 does the initialize statement do ?

2 Answers  


How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?

0 Answers  


What are the different rules to perform a Search?

0 Answers  


what is the size of W-REC in the following 01 W-REC 05 A PIC 9(4)V99 05 B READLINES A 10 C PIC XX 10 D PIC S9(4) 05 E OCCURS 7 PIC ZZ.ZZ 05 F OCCURS 5 10 G PIC ZZ.ZZZ99 10 H OCCURS 3 15 J PIC 9(3) 15 K PIC V99

2 Answers   TCS,


can we use variable picture clause as xx.99 in cobol.

3 Answers  


01 var1 pic x(10) 01 var2 redefines var1 pic 9(10). then in procedure division move 'abcde' to var1 then waht is the value of var1 and var2

9 Answers   HSBC,


how to crack cts interview apps? NOVEMBER 21 2010

2 Answers   CTS,


input 1 input2 ouput1 output2 output 3 1 re 300 1 re 200 1 re 300 3 rc 500 1 re 200 2 rr 400 1 re 300 2 rr 400 1 rc 400 3 rc 500 1 rc 400 2 rr 700 2 rr 700 5 tt 900 5 tt 900 2 inputs r in flat file and output 1 is matched records,ouptput2 is unmatched of input1,output3 is unmatched of input2! how vl u get the output files using sequential order and to check with each and every records! let me know the procedure division ?

0 Answers  


What is length is cobol?

0 Answers  


We have 3 programms A,B,C.In the middle of the program A the controls goes to program B and in the middle of the program B control wants to go program C,after completion of program C again control comes to program B and again after completion of program B control comes to program A.How the process will takes and what are the controls we use for that process.If it is possible anybody of you explain with example?

5 Answers   IBM,


wht do u mean by (*,intrdr) wht is * used for ?

2 Answers  


can we declare s9(9)v9(9) in cobol ? if yes how many bytes it will occupy ?(urgent plz answer it)

13 Answers   CTS,


Categories