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 inspect in cobol ?
Can a Search can be done on a table with or without Index?
Difference between array and sub-script ?
if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.
what is amode(24), amode(31), rmode(24) and rmode(any)?
What is the difference between a binary search and a sequential search what are the pertinent cobol?
What is the Purpose of Pointer in the string?
How to get the last record in vsam file in cluster? And how can you get the ksds file records into your cobol program?
What are the cobol coding sheets?
What are various search techniques in cobol? Explain.
how can i see junk values in dclgen or in hostvariable of comp ?
Explain about different table spaces.
How many bytes S(8) comp field occupy and its maximum value?
What kind of error is trapped by on size error option?
Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.