Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to print addition of two numbers and print if summation is equal to third number or not

Posted By: Imogen Brown     Category: Cobol     Views: 4624

Program to print addition of two numbers and print if summation is equal to third number or not.

Code for Program to print addition of two numbers and print if summation is equal to third number or not in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ASS2.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL
           SELECT OUT2 ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD OUT2
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "OUT2.TXT".
       01 OUT-REC.
          05 MSG-OUT PIC X(30).
       WORKING-STORAGE SECTION.
       77 NO1 PIC 9(2) VALUE IS 10.
       77 NO2 PIC 9(2) VALUE IS 20.
       77 NO3 PIC 9(2) VALUE IS 30.
       77 ANS PIC 9(3).
       PROCEDURE DIVISION.
       MAIN-PARA.
           OPEN OUTPUT OUT2.
           COMPUTE ANS = NO1 + NO2.
           IF ANS = NO3
              DISPLAY "no1 + no2 = no3"
              MOVE 'no1 + no2 = no3.' TO MSG-OUT
           ELSE
              DISPLAY "no1 + no2 <> no3"
              MOVE 'no1 + no2 <> no3' TO MSG-OUT.
           WRITE OUT-REC.
           CLOSE OUT2.
           STOP RUN.


Input:-
100100200

Output:-
no1 + no2 = no3.              
  
Share: 



Imogen Brown
Imogen Brown author of Program to print addition of two numbers and print if summation is equal to third number or not is from London, United Kingdom.
 
View All Articles

 
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!