O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

COBOL

COBOL is an acronym for Common Business Oriented Language and was developed in the late 1950s by Grace Hopper for the purpose of writing business-related programs, which she felt should be written in English. However, it seems rather that the language was developed with the express purpose of avoiding all mathematical-like notation, with the inevitable consequence that conciseness and readability is also avoided.

At any rate, I could only bring myself to code a COBOL sample program that adds two numbers:

	* COBOL PROGRAM TO ADD TWO NUMBERS

	IDENTIFICATION DIVISION.
	PROGRAM-ID.ADD02.
	ENVIRONMENT DIVISION.
	DATA DIVISION.

	WORKING-STORAGE SECTION.
	01          FIRST-NUMBERPIC IS 99.
	01          SECOND-NUMBERPIC IS 99.
	01          SUM                 PIC IS 999.

	PROCEDURE DIVISION.

	PROGRAM-BEGIN.

	DISPLAY "ENTER FIRST NUMBER ".
	ACCEPT FIRST-NUMBER.

	DISPLAY "ENTER SECOND NUMBER ".
	ACCEPT SECOND-NUMBER.

	COMPUTE SUM = FIRST-NUMBER + SECOND-NUMBER

	DISPLAY "THE SUM IS: " SUM.

	PROGRAM-DONE.
	STOP RUN.

In BASIC, the preceding program would be:

	INPUT "Enter first number: ", n1
	INPUT "Enter second number: ", n2
	PRINT "The sum is: ", n1 + n2

This clearly points out the extreme verbosity of COBOL.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required