Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to perform arithmetic operations addition, subtraction, division and multiplication

Posted By: Sara Hughes     Category: Cobol     Views: 22179

PROGRAM WHICH TAKE TWO INPUT FROM THE USER AND PERFORM ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION OPERATION ON IT.

Code for Program to perform arithmetic operations addition, subtraction, division and multiplication in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. addpro.
       
       DATA DIVISION.
        WORKING-STORAGE SECTION.
           77 num1 PIC 9(2).
           77 num2 PIC 9(2).
           77 res PIC 9(2).

       PROCEDURE DIVISION.  
       disres.
           
      *ACCEPT THE NUMERS FROM USER.
           DISPLAY "ENTER NUM1".
           ACCEPT num1.
           
           DISPLAY "ENTER NUM2".
           ACCEPT num2.
         
      *ADDITION OF TWO NUMBER.  
           ADD num1,num2 TO res.
           DISPLAY "ADDITION OF " num1 " AND " num2 " IS " res.
      
      *MULTIPLICATION OF TWO NUMBERS.
           MULTIPLY num1 BY num2 GIVING res.
           DISPLAY "MULTIPLICATION OF " num1 " AND " num2 " IS " res.

      *SUBTRACTION OF TWO NUMBERS.     
           SUBTRACT num1 FROM num2 GIVING res.
           DISPLAY "SUBTRACTION Of " num1 " FROM " num2 " IS " res.

      *DIVITION OF TWO NUMBERS.
           DIVIDE num1 BY num2 GIVING res.
           DISPLAY num1 " DEVIDE BY " num2 " IS " res.
           
           STOP RUN.

**********************************************************************
ENTER NUM1
12

ENTER NUM2
12

ADDITION OF 12 AND 12 IS 24
MULTIPLICATION OF 12 AND 12 IS 144
SUBTRACTION Of 12 FROM 12 IS 0
12 DEVIDE BY 12 IS 1

**********************************************************************
  
Share: 



Sara Hughes
Sara Hughes author of Program to perform arithmetic operations addition, subtraction, division and multiplication is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!