21 January 2012

A simple Cobol program that accepts two numbers and adds them together

000100 ID DIVISION.
000200 PROGRAM-ID. ACCEPT1.
000300 DATA DIVISION.
000400 WORKING-STORAGE SECTION.
000500 01 WS-FIRST-NUMBER PIC 9(3).
000600 01 WS-SECOND-NUMBER PIC 9(3).
000700 01 WS-TOTAL PIC ZZZ9.
000800*
000900 PROCEDURE DIVISION.
001000 0000-MAINLINE.
001100 DISPLAY 'ENTER A NUMBER: '.
001200 ACCEPT WS-FIRST-NUMBER.
001300*
001400 DISPLAY 'ANOTHER NUMBER: '.
001500 ACCEPT WS-SECOND-NUMBER.
001600*
001700 COMPUTE WS-TOTAL = WS-FIRST-NUMBER + WS-SECOND-NUMBER.
001800 DISPLAY 'THE TOTAL IS: ', WS-TOTAL.001900 STOP RUN.

0 comments:

Post a Comment