Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
COBOL CALL statement inside PERFORM

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Fri Nov 23, 2007 2:36 pm    Post subject: COBOL CALL statement inside PERFORM
Reply with quote

The MAINPRG COBOL program is displayed below. For this program, if the variables X, Y, and Z are assigned the values "1", "5", and "50", which of the following are the possible outputs upon executing this program?
PERFORM VARYING X FROM 1 BY Y UNTIL X>Z
CALL CHECKPRG USING X,Y,Z
END-PERFORM.
DISPLAY X,Y,Z.

The PROCEDURE DIVISION of CHECKPRG is displayed below.

PROCEDURE DIVISION USING X1,Y1,Z1.
IF Z1>Y1 AND Y1>X1
DIVIDE Z1 BY X1 GIVING Y1
ELSE GOBACK.

A. 35, 15, 45
B. 5, 10, 50
C. 20, 15, 45
D. 5, 15, 45
E. 50, 15, 45
Back to top
View user's profile Send private message

iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Fri Nov 23, 2007 6:34 pm    Post subject: Reply to: COBOL CALL statement inside PERFORM
Reply with quote

Hi

I tried executing your code and I am getting the result as 51 50 50 which is not available in your options that you have listed. Also I got a U1037 ABEND upon execution.

Please let me know the result if anybody else tried executing the same program.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Fri Nov 23, 2007 7:14 pm    Post subject: Reply to: COBOL CALL statement inside PERFORM
Reply with quote

Hi

I have fixed the problem (U1037 abend) and upon execution I am still getting the result as "51 50 50".
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Nov 23, 2007 8:05 pm    Post subject:
Reply with quote

Just tracing through I get the same as iknow. The time through, in the subprogram:

Y1 = Z1/X1
Y1 = 50/1
Y1 = 50

and then after that the IF logic in the subprogram is always false and the divide will never happen again. Leaving Y = 50 and Z is never changed so that must be 50 and you loop until X > Z so X must be 51
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us