Program for subtract verb, COBOL Programming


We have to write a simple program to elaborate the SUBTRACT verb. You can also use edit characters in the program.

Identification division.

Program- id. Subverb.

Environment division.

Data division.

Working-storage section.

77  a  pic   s9(3)v9(2) value 0.

77  b  pic    s9(3)v9(2) value 0.

77  e-b pic  +z(3).z(2).


Procedure division.


  Display(1 1) erase.

   Display(3 5) "Enter first number :".

  Accept a.

  Display(5 5) "Enter second number :".

  Accept b.

  Subtract a  from b.

  Move b to e-b.

  Display(15 5) "b-a = " e-b.

  Stop run.

Description:   This program gets 2 inputs from the user.

                      It subtracts them by using the SUBTRACT verb. 

                      b-a is computed and stored in b.

                      Afterward the execution: OLD value of a is similar

                                                             OLD value of b is lost and

                                                             b-a is stored in b.

                     The unedited result is available in the b.

                     We move b to e-b, where the edit characters are available.

                     Note that the variable e-b makes proper use of the + edit character.

                       The e-b will always be exhibited with result.

Posted Date: 10/17/2012 1:28:29 AM | Location : United States

Related Discussions:- Program for subtract verb, Assignment Help, Ask Question on Program for subtract verb, Get Answer, Expert's Help, Program for subtract verb Discussions

Write discussion on Program for subtract verb
Your posts are moderated
Related Questions
Floating Insertion   The currency symbol ($) can emerge in multiples on the left-hand side of the picture. In this situation the character will be treated in similar way as t

Label Records / Disk Directory: The most important information stored in the header label is what is termed as the file title. In the situation of magnetic-disk files the labe

Valid and Invalid Word - Cobol words: Valid Word             Invalid Word & Reason emp-sal                  -pay   ( it starts with a hyphen)  TOTAL MARK (blank space em

RULES OF REDEFINES CLAUSE The rules shown below govern the use of the REDEFINES clause: (i) The level-number of data-name-1 and data-name-2 should be identical. (ii) Exce

ROUNDED OPTION: Let us consider the DATA DIVISION entries which are as shown below: Now, subsequent to the execution of the statement ADD A B GIVING C, the C will hold

Plus Sign - edit characters for numeric data: + (Plus Sign) : A plus sign is alike to minus sign except that when the item is positive, +sign will be inserted rather th

Display control verbs in Cobol

Transaction file : A transaction file is a file which contains new records those changes to old records which are used to update the master file. The problem of file updatio

RELATIVE FILES: The Files that are stored on a direct access storage medium like magnetic disk are frequently known as direct access files. The COBOL supports three different

Write a COBOL IF sentence to use the values of numeric variables EXAM and COURSEWORK , both assumed to be with format PIC 999 and in the range 0 to 100 and to move the value: