Microsoft Office Tutorials and References
In Depth Information
01 FIRST-NUMBER PIC IS 99.
01 SECOND-NUMBER PIC IS 99.
01 SUM PIC IS 999.
DISPLAY "ENTER FIRST NUMBER ".
DISPLAY "ENTER SECOND NUMBER ".
COMPUTE SUM = FIRST-NUMBER + SECOND-NUMBER
DISPLAY "THE SUM IS: " SUM.
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.
BASIC, C, Pascal, and FORTRAN are in many ways quite similar. Also, programs written in
these languages can be made quite readable, especially if the programmer intends to make it so.
There are other languages that seem not to be readable under any circumstances. For instance,
LISP was developed in the late 1950s by John McCarthy and Marvin Minsky at MIT, for the
purpose of doing list processing (hence the name) in connection with artificial intelligence
In LISP, everything is a list. Here is a sample:
; LISP sample program to define a predicate
; that takes two lists and returns the value
; T (for true) if the lists are equal and F otherwise
'(equal (LAMDBA (list1 list2)
((ATOM list1) (EQ list1 list2))
((ATOM list1 NIL)
((equal (CAR list1) (CAR list2))