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
What is a SSRANGE and NOSSRANGE?
what is amode(24), amode(31), rmode(24) and rmode(any)?
explain sorting techniques in cobol program?
What is the local-storage section?
Define cobol?
How are the next sentence and continue different from each other?
Have you used the sort in your project?for this type of questions any working on real time project give the eg. with real time scenario.
In COBOL programming, what is PERFORM? What is VARYING?
What is the default value(s) for an initialize and what keyword allows for an override of the default?
What is difference between static and dynamic call in cobol?
How do you code cobol to access a parameter that has been defined in jcl? And do you code the parm parameter on the exec line in jcl?
What is the difference between PIC 9.99 and 9v99 in COBOL?
How to find out the closest prime number of an input number? I believe it has something to do with SEARCH and COBOL Linear Array.
What are the access modes of START statement?
Can you please let me know the centre name of INS certification in Kolkata.