Friday, December 17, 2010

COBOL Tutorial – Arithmetic Operators

Q. How do you perform Arithmetic in COBOL? For example, how do you write a simple program that calculates the Interest to be paid on a Principal p?

You often need to do Math in COBOL. You can perform Arithmetic in COBOL using Arithmetic Operators. When you perform some arithmetic on two or more numeric quantities, such an expression is called an Arithmetic Expressions. There are 4 main Arithmetic Operators in COBOL – ADD, SUBTRACT, MULTIPLY and DIVIDE.

You can even write complex arithmetic expressions by using the COMPUTE verb. I have written about the syntax of each operator, followed by examples and some results.