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
How to print 10 to 1 if the input have only 10 digit number?
Write a program to explain size error.
write a cobol logic. i have file that has 10 records .1 record go to first output file and second record goes to 2 output and etc
how do you reference the ksds vsam file formats from cobol programs
What is the use of intialize verb?
What do you understand by psb and acb?
What is amode(24)?
how we sort two input files based on a common column and giving one o/p file please send me the coding logic?
What are the pertinent COBOL commands?
1.give the details about WHEN OTHER. 2. how many form are available in evaluate.
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.
HOw can I get the negative sign while deduct high value from low value
What guidelines should be followed to write a structured cobol prgm?
how to move the records from file to array table. give with code example
What is rmode(24)