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


Please Help Members By Posting Answers For Below Questions

What is amode(24)?

686


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

1964


What is report-item in COBOL?

718


How many bytes S(8) comp field occupy and its maximum value?

1644


Name the divisions, which are available in a cobol program?

695






Difference between array and sub-script ?

1171


how to access the file from prodution from changeman tool and to submit a file to production

6695


What are the different data types in cobol?

801


What is the use of intialize verb?

758


How can you get the ksds file records into your cobol program?

648


In COBOL programming, what is PERFORM? What is VARYING?

676


input 1 input2 ouput1 output2 output 3 1 re 300 1 re 200 1 re 300 3 rc 500 1 re 200 2 rr 400 1 re 300 2 rr 400 1 rc 400 3 rc 500 1 rc 400 2 rr 700 2 rr 700 5 tt 900 5 tt 900 2 inputs r in flat file and output 1 is matched records,ouptput2 is unmatched of input1,output3 is unmatched of input2! how vl u get the output files using sequential order and to check with each and every records! let me know the procedure division ?

1883


What happens when we move a comp-3 field to an edited (say z (9). Zz-)?

791


Can we change the password using ALTER? anyone tried and changed?

1554


What is the default value(s) for an initialize and what keyword allows for an override of the default?

701