how we can reverse the string in the cobol for example
satheesh can be reveresed as hseehtas
Answers were Sorted based on User's Feedback
Answer / g venkatesh
data division.
01 ws-input pic x(8).
01 ws-output pic x(8).
01 i pic 9.
01 j pic 9.
procedure division.
move 1 to i.
perform varying j from 8 by -1 until j =0
move ws-input(i:1) to ws-output(j:1)
add 1 to i
end-perform
display ws-output.
stop run.
Is This Answer Correct ? | 51 Yes | 7 No |
Answer / adarsh
This can be achieved using
1. FUNCTION REVERSE - RECOMMENDED
2. REFERENCE MODIFICATION
.
1. MOVE FUNCTION REVERSE(WS-NAME-INPT) TO
WS-NAME-RVRS.
2. MOVE WS-NAME-INPT(1:1) TO WS-NAME-RVRS(8:1)
MOVE WS-NAME-INPT(2:1) TO WS-NAME-RVRS(7:1)
MOVE WS-NAME-INPT(3:1) TO WS-NAME-RVRS(6:1)
MOVE WS-NAME-INPT(4:1) TO WS-NAME-RVRS(5:1)
MOVE WS-NAME-INPT(5:1) TO WS-NAME-RVRS(4:1)
MOVE WS-NAME-INPT(6:1) TO WS-NAME-RVRS(3:1)
MOVE WS-NAME-INPT(7:1) TO WS-NAME-RVRS(2:1)
MOVE WS-NAME-INPT(8:1) TO WS-NAME-RVRS(1:1).
Is This Answer Correct ? | 19 Yes | 6 No |
Answer / paul
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 9.
01 J PIC 9.
01 ST1 PIC X(5).
01 ST2 PIC X(5).
PROCEDURE DIVISION.
MOVE 1 TO I.
MOVE 'KOTI' TO ST1.
PARA-A.
PERFORM PARA-B VARYING J FROM 5 BY -1 UNTIL J = 0.
DISPLAY 'STRING REVERSE' ST2.
STOP RUN.
PARA-B.
MOVE ST1(I:1) TO ST2(J:1).
ADD 1 TO I.
Is This Answer Correct ? | 5 Yes | 1 No |
How many times the loop runs here 01 a pic 9(2) value 1. perform para1 until a=10 move 1 to a. stop run. para1: move 10 to a.
Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?
Why there is no questions in this column?
If i got a job on mainframe technology, will i have a bright future?. Some people are discouraging me. Let me know, is it true? Please bring back me from the confusion.
In a COBOL program, 2 tables TABLE1 and TABLE2 are defined that are indexed by INDEX1 and INDEX2 respectively. Can we use INDEX1 with TABLE2 and INDEX2 with TABLE1?
can we redefine 77 level item is it possible
How can we find out wether to declare the data items like Integer, Char,Comp? If comp types how can we decide wether it is Comp and Comp3.How it is? Please Explain... Cheers.
if you code move high-values to variable,can you move it into numeric variable or alphanumeric variable?
What is the usage of comp fields in cobol?
What is the difference between Call and a Link?
There are two flat files one having 10 records and other having 5 records. write a cobol pgm to find the duplicate records(matching records)from both files.
01 NAME1 PIC X(13) VALUE "COBOL PROGRAMMING". 01 NAME2 PIC X(13). now I want to display the value of NAME1 in reverse order i.e value should be displayed as "GNIMMARGORP LOBOC" HOW can I do that ??? please let me know if any one knows it.