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

HOw can I get the negative sign while deduct high value from low value

1781


What is perform what is varying?

698


What is the Purpose of Pointer in the string?

637


What is the local-storage section?

675


What are the different open modes available in cobol?

713






Can you please let me know the centre name of INS certification in Kolkata.

1709


How to know whether the module is dynamical or statistical?

650


IDENTIFICATION DIVISION. PROGRAM-ID. UPDT. AUTHOR.anbu. DATE-WRITTEN. AUG 13. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CMSTR ASSIGN TO CINP1 ORGANIZATION IS INDEXED ACCESS IS SEQUENTIAL RECORD KEY CM2-KEY FILE STATUS IS WS-CMSTR-FST. SELECT CTAB ASSIGN TO CINP2 ORGANIZATION IS ACCESS IS SEQUENTIAL RECORD KEY VSAM-WHSE- KEY FILE STATUS IS WS-CTAB- FST. DATA DIVISION. FILE SECTION. FD CMSTR. COPY RXCYFC20. FD CTAB. COPY AITYWHSE. ************************************************************ ****** *** WORKING STORAGE VARIABLES *** ************************************************************ ****** WORKING-STORAGE SECTION. 01 WS- VARIABLES. 05 WS-EB PIC X(02) VALUE ZEROES. 05 WS-DIV PIC 9(03) VALUE ZEROES. 05 WS-CMF-RECS-REWRITTEN PIC 9(01) VALUE ZERO. *** FILE STATUS VARIABLES *** 05 WS- FILESTATUS. 10 WS-CMSTR-FST PIC 9(02) VALUE ZEROES. 10 WS-CTAB-FST PIC 9(02) VALUE ZEROES. *** END OF FILE VARIABLES *** 05 WS-CMSTR-EOF PIC X(01) VALUE 'N'. 88 WS-CMSTR-EOF-YES VALUE 'Y'. 88 WS-CMSTR-EOF-NO VALUE 'N'. 05 WS-CTAB-EOF PIC X(01) VALUE 'N'. 88 WS-CTAB-EOF-YES VALUE 'Y'. 88 WS-CTAB-EOF-NO VALUE 'N'. **** ERROR VARIABLES **** 05 WC-ABEND-900 PIC 9(03) VALUE 900. 05 WE-ERR-CODE PIC 9(02) VALUE ZEROES. 05 WE-ABEND-CODE PIC 9(03) VALUE ZEROES. ************************************************************ **** ********* PROCEDURE DIVISON ********** ************************************************************ **** PROCEDURE DIVISION. 0000- BEGIN. PERFORM 1000-INITIALISE THRU 1000- EXIT. PERFORM 2000-PROCESS THRU 2000- EXIT UNTIL WS-CMSTR-EOF- YES. DISPLAY 'WS-CMF-RECS-REWRITTEN :' WS-CMF-RECS- REWRITTEN. PERFORM 5000-CLOSE THRU 5000- EXIT. GOBACK. 0000- EXIT. EXIT. 1000- INITIALISE. OPEN I-O CMSTR. EVALUATE WS-CMSTR- FST WHEN 00 WHEN 97 CONTINUE WHEN OTHER DISPLAY 'ERROR IN READING INPUT FILE: ' DISPLAY WS-CMSTR-FST MOVE WS-CMSTR-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END-EVALUATE. OPEN INPUT CTAB. EVALUATE WS-CTAB-FST WHEN 00 WHEN 97 CONTINUE WHEN OTHER DISPLAY 'ERROR IN READING INPUT FILE: ' DISPLAY WS-CTAB-FST MOVE WS-CTAB-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END-EVALUATE. 1000-EXIT. EXIT. 2000-PROCESS. READ CMSTR. EVALUATE WS-CMSTR-FST WHEN 00 CONTINUE WHEN 10 SET WS-CMSTR-EOF-YES TO TRUE GO TO 2000-EXIT WHEN OTHER DISPLAY 'ERROR IN READING INPUT FILE: ' DISPLAY WS-CMSTR-FST MOVE WS-CMSTR-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END-EVALUATE IF CM2-RECORD-TYPE-SOLD-TO MOVE CM2-ENTERING-BRANCH TO WS-EB PERFORM 3000-READ THRU 3000-EXIT UNTIL WS-CTAB-EOF-YES END-IF. 2000-EXIT. EXIT. 3000-READ. MOVE WS-EB TO VSAM-WHSE-CD. MOVE 'WHSE' TO VSAM-WHSE-ID. READ CTAB. EVALUATE WS-CTAB-FST WHEN 00 MOVE WHSE-DIV-CODE TO WS-DIV PERFORM 4000-REWRITE-CMF THRU 4000-EXIT WHEN 10 SET WS-CTAB-EOF-YES TO TRUE GO TO 3000-EXIT WHEN OTHER DISPLAY 'ERROR IN READING TABLE FILE: ' DISPLAY WS-CTAB-FST MOVE WS-CTAB-FST TO WE-ERR-CODE PERFORM 9999-ABEND-PARA THRU 9999-EXIT END- EVALUATE. 3000- EXIT. EXIT. 4000-REWRITE- CMF. IF WS-DIV = 250 OR 252 MOVE 'F' TO CM2-FREIGHT- TYPE MOVE 1 TO CM2-FREIGHT-THRESHOLD- AMT ADD +1 TO WS-CMF-RECS- REWRITTEN REWRITE CM2-SOLD-TO- RECORD DISPLAY 'RECORD UPDATED' END- IF. * EVALUATE WS-CMSTR- FST * WHEN 00 * CONTINUE * WHEN OTHER * DISPLAY 'FILE NOT UPDATED' * DISPLAY WS-CMSTR- FST * MOVE WS-CMSTR-FST TO WE-ERR-CODE * PERFORM 9999-ABEND-PARA THRU 9999-EXIT * GO TO 4000-EXIT * END-EVALUATE. 4000-EXIT. EXIT. 5000-CLOSE. CLOSE CMSTR CTAB. 5000-EXIT. EXIT. 9999-ABEND-PARA. COMPUTE WE-ABEND-CODE = WC-ABEND-900 + WE-ERR-CODE CALL 'ILBOABN0' USING WE-ABEND-CODE GO TO 5000-CLOSE. 9999-EXIT. EXIT. 5000-CLOSE. CLOSE CMSTR CTAB. 5000-EXIT. EXIT. 9999-ABEND-PARA. COMPUTE WE-ABEND-CODE = WC-ABEND-900 + WE-ERR-CODE CALL 'ILBOABN0' USING WE-ABEND-CODE GO TO 5000-CLOSE. 9999-EXIT. EXIT. //this program is giving maxcc=0, but not updating..

3333


How do we get current date from system with century in COBOL?

793


What is comp-1 and comp-2?

755


Explain how to differentiate call by context by comparing it to other calls?

680


can anybody post me about file-aid and changemen tools pls and give me reference if any mainframe guys are there

1833


Give some examples of command terminators?

749


What is the difference between structured cobol programming and object alternativelyiented cobol programming?

700


How do define dynamic array in cobol. how do you define single dimensional array and multidimensional array in your cobol?

697