如:1到10的奇数和相加。用线外perform和线上perform。
IDENTIFICATION DIVISION.
PROGRAM-ID. ADD1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(2).
01 SUMA PIC 9(2).
PROCEDURE DIVISION.
MOVE 1 TO A.
MOVE 0 TO SUMA.
PERFORM 100-ADD
UNTIL A > 10.
DISPALY 'SUMA : ' SUMA.
STOP RUN.
100-ADD.
ADD A TO SUMA.
ADD 2 TO A.
IDENTIFICATION DIVISION.
PROGRAM-ID. ADD1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(2).
01 SUMA PIC 9(2).
PROCEDURE DIVISION.
MOVE 1 TO A.
MOVE 0 TO SUMA.
PERFORM UNTIL A > 10
ADD A TO SUMA
ADD 2 TO A
END-PERFORM.
DISPALY 'SUMA : ' SUMA.
STOP RUN.
区别点如下:
1,线外perform语句后接的是段名,而线上perform后面直接接until。
2,线外perform以句点结尾,线外perfrom是以end-perform结束。
3,线外perform在until后直接结束,而线上perform在until后还将执行相应过程。
该如何实现计算1到100的奇数和,偶数和,全体实数为5的倍数的总和呢????
在一个代码中实现。。。。