input:- 12233344445555566666...
output:- 1=1,2=4,3=9...
Here firstno i.e 1 should be displayed and after that the
alikeno.s should be added n displayed.i.e 2+2=4 like tat it
goeson.
Answer Posted / veena (ibm)
identification division.
program-id. calculationprg.
data division.
working-storage section.
01 ws-num.
02 ws-num1 occurs n times.
03 ws-num2 pic 9(2).
01 ws-result.
02 ws-result1 occurs n times.
03 ws-result2 pic 9(2).
01 ws-calc.
02 ws-calc1 occurs n times.
03 ws-calc2 pic 9(2).
03 ws-times pic 9(2).
05 n pic 9(2) val zero.
05 ws-count pic 9(2).
05 ws-num3 pic 9(2).
Procedure division.
display 'enter the length of number you want to input'
accept n.
display 'enter the input'
perform n times
accept ws-num2(ws-count)
display 'enter next number'
ws-count = ws-count+1
end-perform.
initialise ws-count.
perform n times
ws-count = ws-count + 1
ws-num3 = ws-num2(ws-count)
if ws-calc2(ws-count) = ws-num3
ws-times(ws-count) = ws-times(ws-count) + 1
else
ws-calc2(ws-count) = ws-num3
ws-times(ws-count) = 1
end-perform.
initialise ws-count.
perform n times
ws-count = ws-count + 1
ws-result2(ws-count) = ws-calc2(ws-count) * ws-times(ws-
count)
end-perform.
initialise ws-count.
perform n times
ws-count = ws-count + 1
display ws-result2(ws-count)
end-perform.
similarly other calculation can be performed.
| Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
What is the difference between Global and External Variables?
What is the default value(s) for an initialize and what keyword allows for an override of the default?
how do you reference the printer file formats from cobol programs
What are the various section in data division and briefly explain them.
can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there
how to convert the recors form vsam file to db2 table tru file aid
if we have " ibm mainframe ",in that how to remove first and last leading space eg:"ibm mainframe" like that the answer we need
how do you reference the esds vsam file formats from cobol programs
How did the release of cobol/370 version 1.3 improve the performance of release 1.1?
How to use the same COBOL program in Batch and CICS on lines? explain with an example
Program A (Normal COBBAT) calling a B Program (DB2COBOL, COBBATDB which is using a VSAM file. its a dynamic call. How we will handle VSAM file decleration in our from JCL from where we are running A PGM. And should we have PLAN for A pGM also. if possible can some one post a sample JCL. Thanks for help in advance.
Why is it necessary that file needs to be opened in I-O mode for REWRITE?
What is the difference between PIC 9.99 and PIC9v99?
What is the compute verb? How is it used?
)If there are 10 steps in GDG, if I want to refer the step2 after step5 . what should I do?