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

I have a file it contain 10 records.i got abend at 8th record because of soc7.how do you know that perticular record got abend?

3 Answers   IBM,


How to remove the spaces at end of each record in the output file Via COBOL program? note: The file has a VB length

2 Answers   IBM, Wipro,


I am sending values a and b with pic x(10) and pic x(10) by using call statement. In linkage section, I am receiving values with pic x(10) and pic x(11). Will my program fail? will it be compile error or run time abend?

3 Answers  


how to crack cts interview apps? NOVEMBER 21 2010

2 Answers   CTS,


Are you comfortable in cobol or jcl?

0 Answers  


what are decleratives in cobol?

0 Answers   GGG, Satyam,


can we use go to statement inline-perform?

7 Answers   IBM,


How to execute a set of JCL statements from a COBOL program?

2 Answers   Patni, Syntel,


What is SSRANGE, NOSSRANGE ?

5 Answers  


What is the local-storage section?

0 Answers  


How to define variable 9(20) in COBOL, because compiler does not allow us to declare variables with Pic 9(18). Can anyone please let me know the answer... I know one answer to this question which is to use Compiler option Arith (Extend) during Compilation. It extends the maximum limit to 9(32)..Just wanted to know if there is any other way to extend this?

4 Answers   CSC, TCS,


input:- A 10 20 30 40 B 5 7 10 14 C 8 12 14 16.... output:- A = 100,B=36,C=50. Here spaces are considered between numbers. When we give input as above, the numbers should be added n displayed.So please help me out.

4 Answers  


Categories