i have a file which contains records like
10,30,90,50,20,40,80,60,70
i want to display these records in reverse order like
70,60,80,40,20,50,90,30,10
please give me the cobol code (do not sort the records)
Answer Posted / preethi
Declare table , and a index variable in the working storage section.
Procedure Division.
Open file1.
perform para1 thru para1-exit until end-of-file.
perform display-para thru display-para-exit.
close file1.
go back.
Para1.
read file1 into ws-file1
at end
end-of-file
set index-diff to index
not at end
move ws-file1-num to table-num(index)
set index up by 1
end-read.
para1-exit.
exit.
Display-para.
subtract 1 from index-diff.
perform until index-diff = 0
display table-num(index-diff)
set index-diff down by 1
end-perform.
display-para-exit.
exit.
| Is This Answer Correct ? | 5 Yes | 3 No |
Post New Answer View All Answers
Whats the difference between search & search ALL?
How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?
Explain sorting techniques in cobol program? Provide the sort file definition, the sort statement, its syntax and meaning
What is the utilization of copybook in cobol? Could we utilize a similar copybook?
What is difference between static and dynamic call in cobol?
How you can characterize tables in cobol?
How to change size of Initial number of records to *NOMAX for ALL PF files from perticular library, how can I do that
When is inspect verb is used in cobol?
What are the different data types in cobol?
What is a report item?
how do you define single dimensional array and multidimensional array in your cobol?
How to read the 2nd last record of a VSAM file? (The file size is huge and we don't know the key)
Write the code implementing the perform … varying.
What are the different rules to perform a Search?
How to get the last record in vsam file in cluster? And how can you get the kids file records into your cobol program?