How to display string in the reverse order using occurs
clause?
Answers were Sorted based on User's Feedback
@fool
Hello Mr.Fool as ur screen name and ur approach suggest u
dont have the basic quality of respecting individuals.Very
sorry to say that this forum is not for abusing anyone nor
it is a place to show individual intellects.I would suggest
that you abstain from commenting and purely provide
solutions to queries posted.You are welcome to do so.
Thanks,
Adim.
| Is This Answer Correct ? | 13 Yes | 1 No |
Answer / fool
both r foolish programmers...heres the working code..
identification division.
program-id pg1.
environment division.
data division.
working-storage section.
01 j pic 99.
01 i pic 99.
01 s1 pic a(15).
01 s2 redefines s1.
02 instr pic a(1) occurs 15 times.
01 s3 pic a(15).
01 s4 redefines s3.
02 outstr pic a(1) occurs 15 times.
procedure division.
p1.
display "Enter the string ".
accept s1.
perform p3 varying i from 15 by -1 until i = 0.
display "Reverse string ".
display s4.
stop run.
p3.
compute j = 15 - i + 1.
move instr(i) to outstr(j).
| Is This Answer Correct ? | 11 Yes | 0 No |
Answer / nk
01 MY-STRING PIC X(9) VALUE 'ABCDEFGHI'.
01 FILLER REDEFINES MY-STRING.
05 CHAR OCCURS 9 TIMES. (could use INDEXED BY here)
01 OUT-STRING PIC X(9).
01 IDX-IN PIC 9.
01 IDX-OUT PIC 9.
MOVE 9 TO IDX-IN.
PERFORM MOVE-A-CHAR (could also do an inline PERFORM)
VARYING IDX-OUT FROM 1 BY 1
UNTIL IDX-OUT > 9.
MOVE-A-CHAR.
MOVE CHAR(IDX-IN) TO OUT-STRING(IDX-OUT).
SUBTRACT 1 FROM IDX-IN.
MOVE-A-CHAR-EXIT.
EXIT.
| Is This Answer Correct ? | 1 Yes | 3 No |
What are different file OPEN modes available in COBOL?
I have a source program compiled with Cobol-2. The output file has a record length of 100 defined in the program but a record of 60 bytes getting written into it. i.e. The rest of 40 bytes I am not Writing anything. But it by default puts some values into the last 40 bytes. However it does not impact anything. But when Compiled the module with Enterprise Cobol the last 40 bytes were spaces as fillers. Can anyone explain?
Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?
6 Answers ABC, IBM, Mphasis, Wipro,
what are the diferences b/w sub-script and index?
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?
can anyone explain me the concept of COMP-4 PLEASE??
What is the difference between a binary search and a sequential search? What are the pertinent cobol commands?
diffrence between renames and redifnes with examples
Can 88 level variable be declared in FD section..?
I have a File that has duplicate records. I need only those records that occur more than thrice.?
I had 100 records and i want to execute last three records by using cobol programming?what will be coding?
Can anyone explain me CALL procedure in COBOL.Does it carries similarities like call by reference in C.