0% found this document useful (0 votes)
13 views11 pages

Com 213 Oocobol

The document outlines a course on Commercial Programming using OOCOBOL at Delta Central College of Management and Sciences, detailing various questions related to COBOL programming, its features, structure, and key concepts. It covers topics such as COBOL's history, importance, programming divisions, data handling, verbs, conditional statements, and string operations. The course includes a marking scheme for evaluating responses to the questions posed.

Uploaded by

Paul Oshos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views11 pages

Com 213 Oocobol

The document outlines a course on Commercial Programming using OOCOBOL at Delta Central College of Management and Sciences, detailing various questions related to COBOL programming, its features, structure, and key concepts. It covers topics such as COBOL's history, importance, programming divisions, data handling, verbs, conditional statements, and string operations. The course includes a marking scheme for evaluating responses to the questions posed.

Uploaded by

Paul Oshos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

DELTA CENTRAL COLLEGE OF MANAGEMENT AND SCIENCES (DECCOMS)

IN AFFILIATION WITH
TEMPLE GATE POLYTECHNIC
ABA, ABIA STATE.
COURSE TITLE: COMMERCIAL PROGRAMMING USING OOCOBOL
COURSE CODE: COM 213 DEPARTMENTS: COMPUTER SCIENCE
TIME ALLOWED: 2 HOURS INSTRUCTIONS: ANSWER FIVE QUESTIONS
QUESTION 1

a. Give a wholistic overview of the COBOL programming language (7 marks)


b. List seven importance of the COBOL language (7 marks)

QUESTION 2

a. Give the four features of COBOL (4 marks)

b. The COBOL programme structure consists of various divisions. Briefly state these
divisions (10
marks)
QUESTION 3
a. What are the five fields of character positions (5 marks)
b. What is a comment and describe the two types of comment (9 marks

QUESTION 4

a. What are figurative constants and description. List five of them (6 marks)
b. Define data name, level number, picture clause and value clause (8 marks)

QUESTION 5

a. What are COBOL verbs (2 marks)


b. Define accept verb, display verb, initialize verb and move verb (8 marks)
c. Give examples of Add verb and Substract Verb (4 marks)
QUESTION 6
a. Give examples of Multiple verb and divide verb (2 marks)
b. What are redefines clause and renames clause (4 marks)
c. What is a COBOL copybook (2 marks)

d. What are conditional statements and state four different types of conditional
statements (6 marks)
QUESTION 7
a. State the loop statements used in COBOL (4 marks)
b. List and explain the three string handling statements (10 marks)
Marking Scheme

1a.

COBOL is a high-level programming language first developed by the CODASYL


Committee (Conference on Data Systems Languages) in 1960. Since then, responsibility for
developing new COBOL standards has been assumed by the American National Standards
Institute (ANSI).Three ANSI standards for COBOL have been produced: in 1968, 1974 and
1985. A new COBOL standard introducing object-oriented programming to COBOL is due
within the next few years. The word COBOL is an acronym that stands for Common
Business Oriented Language. As the expanded acronym indicates, COBOL is designed for
developing business, typically file-oriented, applications. It is not designed for writing
systems programs. For instance you would not develop an operating system or a compiler
using COBOL. For over four decades COBOL has been the dominant programming
language in the business computing domain. In that time it has seen off the challenges of a
number of other languages such as PL1, Algol68, Pascal, Modula, Ada, C, C++. All these
languages have found a niche but none has yet displaced COBOL. Two recent challengers
though, Java and Visual Basic, are proving to be serious contenders. COBOL’s dominance in
underlined by the reports from the Gartner group. In 1997 they estimated that there were
about 300 billion lines of computer code in use in the world. Of that they estimated that
about 80% (240 billion lines) were in COBOL and 20% (60 billion lines) were written in all
the other computer languages combined.

In 1999 they reported that over 50% of all new mission-critical applications were still
being done in COBOL and their recent estimates indicate that through 2004-2005 15% of all
new applications (5 billion lines) will be developed in COBOL while 80% of all deployed
applications will include extensions to existing legacy (usually COBOL) programs.

Gartner estimates for 2002 are that there are about two million COBOL programmers world-
wide compared to about one million Java programmers and one million C++ programmers.

COBOL is one of the oldest programming languages in use. As a result it has some
idiosyncrasies which programmers used to other languages may find irritating. When
COBOL was developed (around the end of the 1950's) 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 themselves tend to be long. COBOL
programs tend to be verbose especially when compared to languages like C. When COBOL
was designed, programs were written on coding forms punched on to punch cards, and
loaded into the computer using a punch card reader. These media (coding forms and punch
cards) required adherence to a number formatting restrictions that some COBOL
implementations still enforce today, long after the need for them has gone. 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 cases impossible, to write good programs.
1b
IMPORTANCE OF COBOL
 COBOL was the first widely used high-level programming language. It is an English-
like language which is user friendly. All the instructions can be coded in simple English
words.
 COBOL is also used as a self-documenting language.
 COBOL can handle huge data processing.

 COBOL is compatible with its previous versions.

 COBOL has effective error messages and so, resolution of bugs is easier.

2a
FEATURES OF COBOL

Standard Language: COBOL is a standard language that can be compiled and executed on
machines such as IBM AS/400, personal computers, etc.
Business Oriented: COBOL was designed for business-oriented applications related to
financial domain, defense domain, etc. It can handle huge volumes of data because of its
advanced file handling capabilities.
Robust Language: COBOL is a robust language as its numerous debugging and testing
tools are available for almost all computer platforms.
Structured Language: Logical control structures are available in COBOL which makes it
easier to read and modify. COBOL has different divisions, so it is easy to debug.

2b A COBOL program structure consists of divisions as shown in the following image −


A brief introduction of these divisions is given below −
 Sections are the logical subdivision of program logic. A section is a collection of
paragraphs.
 Paragraphs are the subdivision of a section or division. It is either a user-defined or
a predefined name followed by a period, and consists of zero or more
sentences/entries.
 Sentences are the combination of one or more statements. Sentences appear only in
the Procedure division. A sentence must end with a period.
 Statements are meaningful COBOL statements that perform some processing.
 Characters are the lowest in the hierarchy and cannot be divisible.
You can co-relate the above-mentioned terms with the COBOL program in the following
example −
Divisions
A COBOL program consists of four divisions.
Identification Division
It is the first and only mandatory division of every COBOL program. The programmer and
the compiler use this division to identify the program. In this division, PROGRAM-ID is the
only mandatory paragraph. PROGRAM-ID specifies the program name that can consist 1 to
30 characters.

3a.
Character positions are grouped into the following five fields −
Position Field Description
s

1-6 Column Numbers Reserved for line numbers.

7 Indicator It can have Asterisk (*) indicating comments,


Hyphen (-) indicating continuation and Slash ( / )
indicating form feed.

8-11 Area A All COBOL divisions, sections, paragraphs and


some special entries must begin in Area A.

12-72 Area B All COBOL statements must begin in area B.

73-80 Identification Area It can be used as needed by the programmer.

Character Strings
Character strings are formed by combining individual characters. A character string can be a

 Comment,
 Literal, or
 COBOL word.
All character strings must be ended with separators. A separator is used to separate
character strings.

Frequently used separators − Space, Comma, Period, Apostrophe, Left/Right Parenthesis,


and Quotation mark.
3b
Comment
A comment is a character string that does not affect the execution of a program. It can be
any combination of characters.
There are two types of comments −
Comment Line
A comment line can be written in any column. The compiler does not check a comment line
for syntax and treats it for documentation.
Comment Entry
Comment entries are those that are included in the optional paragraphs of an Identification
Division. They are written in Area B and programmers use it for reference.

4a.
Figurative constants are constant values like ZERO, SPACES, etc. All the constant values
of figurative constants are mentioned in the following table.
Figurative Constants
Sr.No. Figurative Constants & Description

1 HIGH-VALUES
One or more characters which will be at the highest position in
descending order.

2 LOW-VALUES
One or more characters have zeros in binary representation.

3 ZERO/ZEROES
One or more zero depending on the size of the variable.

4 SPACES
One or more spaces.

5 QUOTES
Single or double quotes.

6 ALL literal
Fills the data-item with Literal.

4b.

 Data Name
 Level Number
 Picture Clause
 Value Clause
5a.
COBOL verbs are used in the procedure division for data processing. A statement always
starts with a COBOL verb. There are several COBOL verbs with different types of actions.

5b.
The following two verbs are used for this process −
Accept Verb
Accept verb is used to get data such as date, time, and day from the operating system or
directly from the user. If a program is accepting data from the user, then it needs to be
passed through JCL.
Display Verb
Display verb is used to display the output of a COBOL program.
Initialize Verb
Initialize verb is used to initialize a group item or an elementary item. Data names with
RENAME clause cannot be initialized. Numeric data items are replaced by ZEROES.
Alphanumeric or alphabetic data items are replaced by SPACES.
Move Verb
Move verb is used to copy data from source data to destination data. It can be used on both
elementary and group data items. For group data items, MOVE CORRESPONDING/CORR
is used. In try it option, MOVE CORR is not working; but on a mainframe server, it will
work.
For moving data from a string, MOVE(x:l) is used where x is the starting position and l is
the length. Data will be truncated if the destination data item PIC clause is less than the
source data item PIC clause. If the destination data item PIC clause is more than the source
data item PIC clause, then ZEROS or SPACES will be added in the extra bytes. The
following example makes it clear.
5c.
Add Verb

Add verb is used to add two or more numbers and store the result in the destination operand.
In syntax-1, A, B, C are added and the result is stored in C (C=A+B+C). A, B, D are added
and the result is stored in D (D = A + B + D).
In syntax-2, A, B, C, D are added and the result is stored in E (E=A+B+C+D).
In syntax-3, sub-group items within WS-GROUP1 and WS-GROUP2 are added and
Subtract Verb

Subtract verb is used for subtraction operations.


In syntax-1, A and B are added and subtracted from C. The result is stored in C (C = C-
(A+B)). A and B are added and subtracted from D. The result is stored in D (D = D-(A+B)).
In syntax-2, A, B, C are added and subtracted from D. The result is stored in E (E = D-
(A+B+C))
In syntax-3, sub-group items within WS-GROUP1 and WS-GROUP2 are subtracted and the
result is stored in WS-GROUP2.

6a.
Multiply Verb
Multiply verb is used for multiplication operations.
In syntax-1, A and B are multiplied and the result is stored in B (B=A*B). A and C are
multiplied and the result is stored in C (C = A * C).
In syntax-2, A and B are multiplied and the result is stored in E (E=A*B).
When you compile and execute the above program, it produces the following result

Divide Verb
Divide verb is used for division operations.
Syntax
Given below is the syntax for division operations −
In syntax-1, B is divided by A and the result is stored in B (B=B/A).
In syntax-2, A is divided by B and the result is stored in C (C=A/B) and the remainder is
stored in R.

6b.
Redefines Clause
Redefines clause is used to define storage with different data description. If one or more
data items are not used simultaneously, then the same storage can be utilized for another
data item. So the same storage can be referred with different data items.
Level numbers of redefined item and redefining item must be the same and it cannot be 66
or 88 level number. Do not use VALUE clause with a redefining item. In File Section, do
not use a redefines clause with 01 level number. Redefines definition must be the next data
description you want to redefine. A redefining item will always have the same value as a
redefined item.

Renames Clause
Renames clause is used to give different names to existing data items. It is used to re-group
the data names and give a new name to them. The new data names can rename across
groups or elementary items. Level number 66 is reserved for renames.

6c.
A COBOL copybook is a selection of code that defines data structures. If a particular data
structure is used in many programs, then instead of writing the same data structure again,
we can use copybooks. We use the COPY statement to include a copybook in a program.
COPY statement is used in the Working Storage Section.

6d. Conditional statements are used to change the execution flow depending on certain
conditions specified by the programmer. Conditional statements will always evaluate to true
or false. Conditions are used in IF, Evaluate, and Perform statements. The different types of
conditions are as follows −

 IF Condition Statement
 Relation Condition
 Sign Condition
 Class Condition
 Condition-Name Condition
 Negated Condition
 Combined Condition

7a.
The loop statements used in COBOL are −

 Perform Thru
 Perform Until
 Perform Times
 Perform Varying
7b.
String handling statements in COBOL are used to do multiple functional operations on
strings. Following are the string handling statements −

 Inspect
 String
 Unstring
Inspect
Inspect verb is used to count or replace the characters in a string. String operations can be
performed on alphanumeric, numeric, or alphabetic values. Inspect operations are
performed from left to right. The options used for the string operations are as follows −
Tallying
Tallying option is used to count the string characters.
The parameters used are −

 input-string − The string whose characters are to be counted.


 output-count − Data item to hold the count of characters.
Replacing
Replacing option is used to replace the string characters.
 input-string − The string whose characters are to be replaced from char1 to char2.
String
String verb is used to concatenate the strings. Using STRING statement, two or more strings
of characters can be combined to form a longer string. ‘Delimited By’ clause is compulsory.
Syntax
Following is the syntax of String verb −
Following are the details of the used parameters −

 ws-string1 and ws-string2 : Input strings to be concatenated


 ws-string : Output string
 ws-count : Used to count the length of new concatenated string
 Delimited specifies the end of string
 Pointer and Overflow are optional
Unstring
Unstring verb is used to split one string into multiple sub-strings. Delimited By clause is
compulsory.

You might also like