section2 - Business Oriented Programming Course 92-252-01...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Business Oriented Programming Course 92-252-01 – Spring 2005 SECTION 2 – COBOL Basics A program is a collection of statements written in a language that the computer understands. A computer executes program statements one after another in sequence until it reaches the end of the program unless some statement in the program alters the order of execution. Computer scientists have shown that any program may written using just 3 main programming constructs: Sequence, Selection, Iteration. Any program consists of three main things: 1. The computer statements needed to do the job 2. Declarations for all of the data items mentioned in the computer statements. 3. A plan, or algorithm, that arranges the computer statements in the program so that the computer executes them in the correct order Here’s an example of COBOL Program. The following program accepts two numbers from the user’s keyboard, multiplies them together and displays the result on the computer screen. We will need a statement to take in the first number and store it in the named memory location (a variable) - Number1 ACCEPT Number1. We will need a statement to take in the second number and store it in the named memory location - Number2 ACCEPT Number2. We will need a statement to multiply the two numbers together and to store the result in the named location - Result MULTIPLY Number1 BY Number2 GIVING Result. We will need a statement to display the value in the named memory location " Result " on the computer screen - DISPLAY "Result is = ", Result. COBOL is one of the oldest programming languages in use so it may have some idiosyncrasies which programmers used to other languages may find irritating. When COBOL was developed one of the design goals was to make it as English-like as possible. As a result, COBOL uses structural concepts normally associated with English prose such as section, paragraph and sentence. It also has an extensive reserved word list with over 300 entries and the reserved words tend to be long. COBOL programs tend to be verbose especially when compared to languages like C.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Although modern COBOL (COBOL 85 and OO-COBOL) has introduced many of the constructs required to write well structured programs it also still retains elements which, if used, make it difficult, and in some
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/10/2009 for the course CIS 252 taught by Professor Unknown during the Spring '05 term at Bloomsburg.

Page1 / 5

section2 - Business Oriented Programming Course 92-252-01...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online