Skip to Main Content
PROGRAMMING IN COBOL/400: 2nd Edition
book

PROGRAMMING IN COBOL/400: 2nd Edition

by James Cooper, Nancy Stern, Robert A. Stern
January 2002
Intermediate to advanced content levelIntermediate to advanced
736 pages
18h 57m
English
Wiley
Content preview from PROGRAMMING IN COBOL/400: 2nd Edition

Chapter 7. COMPUTING IN COBOL: THE ARITHMETIC VERBS

CHAPTER OBJECTIVES

Upon completion of this chapter, you should be able to

  • Demonstrate the various formats of the ADD, SUBTRACT, MULTIPLY, and DIVIDE operations.

  • Demonstrate the various options that are available with the arithmetic operations.

  • Demonstrate the use of scope terminators.

  • Demonstrate the use of the COMPUTE statement.

  • Demonstrate the use of the INITIALIZE statement.

  • Demonstrate the use of the LIKE clause.

THE FOUR BASIC ARITHMETIC OPERATIONS

All the basic arithmetic operations, ADD, SUBTRACT, MULTIPLY, and DIVIDE, require that the fields operated on (1) have numeric PICTURE clauses and (2) actually have numeric data when the program is executed. Keep in mind that the data-fields specified in any arithmetic statement must be defined in the DATA DIVISION, either in an input or output area of the FILE SECTION, or in the WORKING-STORAGE SECTION. Let us consider each of these arithmetic operations.

ADD STATEMENT

A simple ADD statement has the following instruction formats.

Instruction Format 1 (ADD . . . TO)

Examples:

ADD STATEMENT

Instruction Format 2 (ADD . . . GIVING)

Examples:

ADD STATEMENT

Instruction Format 3 (ADD..TO..GIVING)

Examples:

ADD STATEMENT

Let us review some rules for ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Designing and Programming CICS Applications

Designing and Programming CICS Applications

John Horswill, Members of the CICS Development Team at IBM Hursley

Publisher Resources

ISBN: 9780471418467Purchase book