input:-AABBCCDDEFGHIIJ
output:- ABCDEFGHIJ
Here in input we hav the duplicate characters i.e repeating
characters.SO we should eliminate the duplicate characters
and should display the output in ascending order.
Answer Posted / sudhansu
ID DIVISION.
PROGRAM-ID. TESTPRG4.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VAR.
10 WS-VARA PIC X(20).
10 WS-VARB PIC X(20).
10 I PIC 99.
10 J PIC 99 VALUE 1.
10 OCR PIC 99 VALUE 1.
10 WS-TAB.
20 WS-REC OCCURS 10 TIMES.
30 WS-ID PIC X(1) .
PROCEDURE DIVISION.
ACCEPT WS-VARA.
MOVE 'A' TO WS-HOLD.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 20
MOVE WS-VAR(I:1) TO WS-ID(OCR)
ADD 1 TO OCR
END-PERFORM.
PERFORM VARYING OCR FROM 1 BY 1 UNTIL OCR > 20
IF WS-REC(OCR) NOT EQUAL TO WS-REC(OCR + 1) THEN
MOVE WS-ID(OCR) TO WS-VARB(J:1)
ADD 1 TO J
ELSE
CONTINUE
END-IF
END-PERFORM.
DISPLAY WS-VARB.
STOP RUN.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between comp and comp-3?
What are the different rules to perform a Search?
What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?
Write the code implementing the perform … varying.
Can a Search can be done on a table with or without Index?
What is a SSRANGE and NOSSRANGE?
Difference between array and sub-script ?
What are the pertinent COBOL
If you are current on the owner of a set, what is the difference between obtain next and obtain first?
Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?
What is the difference between binary search and sequential search?
Explain how to differentiate call by context by comparing it to other calls?
In which area will you utilize 88 level items in cobol?
What rules are followed by the search verb.
what is amode(24), amode(31), rmode(24) and rmode(any)?