How to display string in the reverse order using occurs
clause?

Answers were Sorted based on User's Feedback



How to display string in the reverse order using occurs clause?..

Answer / admin

@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

How to display string in the reverse order using occurs clause?..

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

How to display string in the reverse order using occurs clause?..

Answer / rookie

Have u missed something.

Out-string must be an array.

01 OUT-STRING PIC X occurs 9 times.

Is This Answer Correct ?    2 Yes 2 No

How to display string in the reverse order using occurs clause?..

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

Post New Answer

More COBOL Interview Questions

Which is not true about evaluate statement

0 Answers  


wht is packed decimal in cobol

2 Answers  


What will happen if we generate GDG +2 version instead of +1 version?

2 Answers   T systems,


Minimum how many Number of Paragraphs are there in ID- Divison?

7 Answers   IBM,


what is the use of keep and pass in disp

1 Answers  






How many bytes S(8) comp field occupy and its maximum value?

0 Answers  


consider two data items 77 W-A PIC 9(3)V99 VALUE 23.75 77 W-B PIC ZZ9V99 VLAUE 123.45 after the statement MOVE W-A TO W-B what will be W-B's value? a.123.75 b.b23.75 (where b indicates space) c.023.75 d.invalid move

5 Answers   TCS,


How do pass the values to the parameters in cobol

2 Answers  


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

0 Answers  


How to read records which is in sequential file in reverse order ? Exp. 1 2 3 4 5 . i want 5 4 3 2 1?please clear my doubt any one

10 Answers   IBM,


how many bytes do SPPPP999 will store?

18 Answers  


Difference between file status codes 02 and 22.... since both are for duplicate key detection.

1 Answers  


Categories