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 / 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 |
01 xxx pic 9(4). 01 yyy pic 9(6). move 123456 into yyy. move yyy to xxx. display yyy. what would be the value of yyy
What is mean by maxcc
what is record label is empty or standard in file description of data division?
how we sort two input files based on a common column and giving one o/p file please send me the coding logic?
What was removed from COBOL in the COBOL II implementation?
How do u find the programs calling the given module, without having doing 3.13 on loadlib/source library?
in cobol perform stmt whether it first checks the condition or not
What is COMP SYNC?
consider the following two IF statements: IF X AND NOT Y MOVE A TO B IF Z=1 OR 9 MOVE A TO B select one of the following data divusion entries which gives identical results for both the above IF statements a.01 Z PIC 9 88 X VALUE 1.9 88 Y VALUE 0.2 THRU 8 b.01 Z PIC 9 88 X VALUE 0.2 THRU 8 Y VALUE 1.9 c.01 Z PIC 9 88 X VALUE 1.9 88 NOT-Y VALUE 0.2 THRU 1.9 d.none of yhe above
Can we move X(7) to S9(7) COMP?
Name the divisions in a COBOL program ?
How can you display the SPOOL information ?