Showing posts with label addition of two numbers in cobol. Show all posts
Showing posts with label addition of two numbers in cobol. Show all posts

Friday, August 12, 2016

Addition of Two Numbers in Cobol

Hi there this will be my first time to write a simple program in COBOL or Common Business Oriented Language to find the sum of the two numbers. In this sample program I am using OPENCOBOLIDE as my cobol compiler. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.
 
 

Sample Program Output


Program Listing

******************************************************************
* Author: MR. JAKE R. POMPERADA
* Date: AUGUST 12, 2016
* Purpose: FIND THE SUM OF TWO NUMBERS
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. ADDITION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 NUM_1 PIC 9(4).
77 NUM_2 PIC 9(4).
77 SOLVE_SUM PIC 9(4).
PROCEDURE DIVISION.
PARA.
DISPLAY "SUM OF TWO NUMBERS IN COBOL".
DISPLAY "".
DISPLAY "ENTER THE FIRST VALUE : ".
ACCEPT NUM_1.
DISPLAY "ENTER THE SECOND VALUE : ".
ACCEPT NUM_2.
COMPUTE SOLVE_SUM = NUM_1 + NUM_2.
DISPLAY "THE TOTAL SUM IS ".
DISPLAY SOLVE_SUM.
STOP RUN.



 

 

Friday, July 31, 2015

Addition of Two Numbers in Cobol

Cobol is one of the earliest high level language know to us it stands for Common Business Oriented Language it is develop by Admiral Grace Hooper the first person who write the first compiler. In this program that I wrote it will ask the user to enter two numbers and then our program will display the total sum of two number given by our user.

If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.




Sample Program Output




Program Listing

 IDENTIFICATION DIVISION.
       PROGRAM-ID. ADD01.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  FIRST-NUMBER      PICTURE IS 99999.
       01  SECOND-NUMBER     PICTURE IS 99999.
       01  THE-RESULT        PICTURE IS 99999.
       PROCEDURE DIVISION.
       PROGRAM-BEGIN.
               DISPLAY "===== ADDITION OF TWO NUMBERS =====".
               DISPLAY "Enter the first number :".
               ACCEPT FIRST-NUMBER.
               DISPLAY "Enter the second number :".
               ACCEPT SECOND-NUMBER.
               ADD FIRST-NUMBER, SECOND-NUMBER GIVING THE-RESULT.
  DISPLAY "The result is : ".
  DISPLAY THE-RESULT.
               STOP RUN.