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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the default value(s) for an initialize? What keyword will allow for an override of the default?

903


If you are current on the owner of a set, what is the difference between an obtain next and obtain first? Actually in which topic will we use dis???Plz explain it clearly

2913


What are 77 levels used for?

877


What is the difference between next sentence and continue in cobol programing language?

993


how do you reference the variable block file formats from cobol programs

972


In which area will you utilize 88 level items in cobol?

939


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

893


What do you understand by psb and acb?

884


) How do u handle errors in BMS macro?

1669


How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that

3009


What is the local-storage section?

916


Is it possible that the redefines clause has different picture clauses compared to the one it redefined?

938


How do you define a variable of comp-1 and comp-2?

951


Write the code implementing the perform … varying.

845


How do define dynamic array in cobol.

901