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


Please Help Members By Posting Answers For Below Questions

What is the difference between comp and comp-3?

692


What are the different rules to perform a Search?

613


What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?

668


Write the code implementing the perform … varying.

638


Can a Search can be done on a table with or without Index?

798






What is a SSRANGE and NOSSRANGE?

812


Difference between array and sub-script ?

1157


What are the pertinent COBOL

2036


If you are current on the owner of a set, what is the difference between obtain next and obtain first?

635


Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?

704


What is the difference between binary search and sequential search?

634


Explain how to differentiate call by context by comparing it to other calls?

680


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

709


What rules are followed by the search verb.

630


what is amode(24), amode(31), rmode(24) and rmode(any)?

688