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
Can we redefine the field of x(200) to less than 200?
what is search and searchall?what is the diffrence between them?give an best example?
Describe the cobol database components?
can you please let me know if there is any walkins for COBOL/PLI/DB2/IMS/JCL in pune other than IBM and ITC infotech
What is the difference between comp and comp-3?
)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?
What is the Purpose of POINTER Phrase in STRING command in COBOL?
what is amode(24), amode(31), rmode(24) and rmode(any)?
what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.
What is amode(24)?
Write a cobol program making use of the redefine clause.
What is the difference between Structured COBOL Programming and Object Oriented COBOL programming?
How to use the same COBOL program in Batch and CICS on lines? explain with an example
What are the access modes of START statement?
I have to write to a outfile where the number of records in that file should be the header of that file using IMS.. can anyone help me in this issue