You are on page 1of 7

Q. Write a COBOL program for Matrix Addition.

1.dentification division.
programe id. x.
enviroment division.
data division.
warking-storage section.
procedure division.
inline perform to reach 2y2 or 3y3 matrix. e.g.
Perform varying I from 1 by 1 until i > 3
Perform varying J from 1 by 1
until J > 3
Add Matrix1(I,J) to
Matrix(I,J)giving
Marix3(I,J)
End-Perfrom
End-Perfrom.

2.identification division.
programe id. x.
enviroment division.
data division.
warking-storage section.
procedure division.
inline perform to reach 2y2 or 3y3 matrix. e.g.
Perform varying I from 1 by 1 until i > 3
Perform varying J from 1 by 1
until J > 3
Add Matrix1(I,J) to
Matrix(I,J)giving
Marix3(I,J)
End-Perfrom
End-Perfrom.

2. Question :
77 I PI 9.
PERFORM VARYING I FROM 1 BY 1 UNTIL>10
DISPLAY 'OK'
END-PERFORM.
What output/msg is likely when this program is executed thru JCL?
A.1.This loop will give compilation error becoz value of I is declared for only one digit , when loop
reaches to 10 it will find mismatching b/w I & the current value i.e. 10.

A.2. It Won't give the compilation error.

At Run time when Varibale I reached to 10 then in working storage variable which is declared as 9(01)
can hold 0 not 10
So Program goes into loop result in Timeout Error S322.

A.3. 77 I PI 9.
PERFORM VARYING I FROM 1 BY 1 UNTIL I >10
DISPLAY 'OK'
END-PERFORM.

--> Hi.. Nothing is there in the above program..we have one loop in the program it will run until I > 10

--> that means it will run until I value becomes 11. Now observe the I values when the loop is running
--> When the first time loop runs I value is I=1.

--> When the second time loop runs I value is I=2.

--> When the third time loop runs I value is I=3.


........
........
--> When the tenth time loop runs I value is I=10. But here comes the trick..

--> I was declared as 77 I PIC 9. it is same as 77 I PIC 9(1). when the loop runs 10th time I value becomes
10.. 10 is a two digit number. But i can hold only one digit number..So here data truncation will be
happened.

Q.3. Question :
What is meant by abbend and what is the difference between abbend and error.
when does and why dose it come.
what are the types?

A.1. Abend is short for Abnormal end, abend is a term used to describe when a program or task ends
without warning. Generally when an abend is encountered the user will receive some type of error
message.

Error occurs because of Syntax problems or dataset disposition issues etc, whereas Abend occurs
because of some functional problems

Types:
SB37 - End of Volume
SE37 - Maximum extents reached
S013 - Member not found
S80A - Region limit violation

A.2. abend occures during the execution of program.error occures before execution of the
program due to the syntax coding in a program.

Q.4. Question :
Write a COBOL program for Matrix Addition?
What are the sections available in Data division in COBOL?
Explain me about Report Section.

A.1. 1) Use inline perform to reach 2y2 or 3y3 matrix. e.g.


Perform varying I from 1 by 1 until i > 3
Perform varying J from 1 by 1
until J > 3
Add Matrix1(I,J) to
Matrix(I,J)giving
Marix3(I,J)
End-Perfrom
End-Perfrom.

2)File Control Setion, Working Storage Section, Linkage Section, Reporting Section, Screen
Section.

Data divisions sections are-


1. File section
2. Working storage section(local variable)
3. Linkage section ( for Sub routine)
4. Report section
5. Screen section ( for Screen design)

Q.5. Question :
Explain the difference between an internal and an external sort, the pros and cons, internal sort
syntax etc.
A.1. internal sort done by cobol & external sort dine by jcl.
the syntax for internal sort is
sort file3 on a/d key key-name using i/p-filename giving o/p-filename

inter sort=cobol
external sort= jcl

Question :
Give brief me about changeman & expidator tool.
A. Expeditor Tool :

This is a debugging tool. Handly tool mostly widely used everywhere. There are two types of
expediting, online exped and batch exped.

For online exped, you may first need to compile and link your module. Supply your link to
the exped job. The exped will pick the module. You can use breakpoint for exped.

Similar is the case for Batch Exped.

Its all depends how your envirnornment allows you to set up.
Question :
What is the difference between RETURN CODE & MAXCC CODE

A. A RETURN_CODE shows the status of each step within a job, the maximum
RETURN_CODE is 256, where as
MAXCC is used for the final output of the programe. If the MAXCC is ZERO then job is
executed successfully. In MAXCC we have 0,2, 4, 8.

RC is the code returned by each step in the JCL

MAXCC is the Maximum of all the return codes of all the steps in JCL.

Question :
Can we reverse the string in cobol ? See the following problem :

77 NAME PIC X(10) VALUE 'MANOJ'


77 SRNAME PIC X(10).

I want JONAM in SRNAME.


A. Through cobol intrinsic function REVERSE also we can do it.
Identification division.
program-id. rev.
data division.
working-storage section.
77 str1 pic x(5).
77 revstr pic x(5).
procedure division.
display "enter string".
accept str.
move function reverse(str) to revstr.
display revstr.
stop run.

Question :
How can we pass data from cobol to JCl?

A.You can pass the data from COBOL to JCL using RETURN-CODE. This is a global variable which can be
accessed by JCL and COBOL. But this is used to hold return code of program.

MOVE 04 TO RETURN-CODE.

You can also open a file in cobol and write to it. This can be used in JCL subsequent steps.

Question :
What is a bind?

A. A bind associates record types with the program work area; for run unit and records it is the
first command issued in the program.

Binding is a process that creates the access path logic for the sql statements within a cobol
program. after precompilation of a cobol program a dbrm(has all the embedded sql statements) is
created. This dbrm is then bound to form a plan(executable form of the sql statements).

Question :

Can we use redefine clause in occurs clause?

A.Yes we can use redefines clause in occurs clauseeg:01 number1 pic x(10) value spaces.01
number2 redefines number1 pic x occurs 10 times.
Question :
What does a FINISH do?
Answers:

It releases all database resources, terminates database processes, writes statistical


information to IDMS and logs the checkpoint.

Question :
How is sign stored in a comp-3 field?

A. It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last
byte, hex 1C if your number is 101, hex 2C if your number is 102, hex 1D if the number is -101,
hex 2D if the number is -102 etc.
Question :
What is the difference between STOP & STOP RUN ?

A. Stop statement provides a means to temporarily suspend execution of an object program...wheares


STOP used with RUN causes the entire run unit to cease execution when it is encountered....

Question :
What is the difference between performing a SECTION and a PARAGRAPH?

Answers:

Performing a SECTION will cause all the paragraphs that are part of the section, to be
performed.

Performing a PARAGRAPH will cause only that paragraph to be performed

Question :
What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? ( applicable to only
MVS/ESA Enterprise Server).

Answers:

These are compile/link edit options.


AMODE - Addressing mode. RMODE - Residency mode.
AMODE(24) - 24 bit addressing. AMODE(31) - 31 bit addressing. AMODE(ANY) - Either 24
bit or 31 bit addressing depending on RMODE.
RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that
call 24 bit programs. (OS/VS Cobol pgms use 24 bit addresses only).
RMODE(ANY) - Can reside above or below 16 Meg line.
http://www.youtube.com/watch?v=--t4mw1JYg4&feature=player_embedded

You might also like