MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cobol puzzle

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
basky_g
Beginner


Joined: 04 Jul 2004
Posts: 5
Topics: 2

PostPosted: Thu Jan 20, 2011 11:16 pm    Post subject: Cobol puzzle Reply with quote

I encountered below puzzle, can anyone help solving it
(ignore the syntax Very Happy )
[code:1:3ea12a2d8c]
IDENTIFICATION DIVISION.
PROGRAM-ID. ABC.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(2) VALUE 0.

PROCEDURE DIVISION.

MAIN-PARA.

Compute A = A + 1.
DISPLAY A
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri Jan 21, 2011 12:34 am    Post subject: Reply with quote

I believe that B will be the output. If you want A then you have to read the manual and I believe INITIALIZE is the keyword you are looking for. You may have to read the COBOL Users Guide as well.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
misi01
Advanced


Joined: 02 Dec 2002
Posts: 629
Topics: 176
Location: Stockholm, Sweden

PostPosted: Fri Jan 21, 2011 5:37 am    Post subject: That depends Reply with quote

Wouldn't the result be dependent on how the program was being run ? Normally (?), when a program is started via JCL, all working-storage is initialized, so A has the value 0 in your example.

If you submit JCL that runs the program, let it run to completion and repeat this 4 times, I would expect answer 1 every time.
On the other hand, if you have a program that, in turn, calls the program above 4 times via a loop, then I would expect answer 2
Back to top
View user's profile Send private message Send e-mail
Anuj Dhawan
Intermediate


Joined: 19 Jul 2007
Posts: 298
Topics: 7
Location: Mumbai,India

PostPosted: Fri Jan 21, 2011 5:45 am    Post subject: Reply with quote

I'm in agreement with misi01.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Jan 21, 2011 7:50 am    Post subject: Reply with quote

unless of course, the invoking program issues a CANCEL before subsequent CALLs in which case A would be the result.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
RonB
Beginner


Joined: 02 Dec 2002
Posts: 93
Topics: 0
Location: Orlando, FL

PostPosted: Fri Jan 21, 2011 8:29 am    Post subject: Reply with quote

dbzTHEdinosauer wrote:
unless of course, the invoking program issues a CANCEL before subsequent CALLs in which case A would be the result.

Only if the called program was dynamically linked. CANCEL has no effect on a statically linked program.
_________________
A computer once beat me at chess, but it was no match for me at kick boxing.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Fri Jan 21, 2011 11:17 am    Post subject: Reply with quote

basky_g,

Please search before posting. Check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=3788&highlight=initial

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
basky_g
Beginner


Joined: 04 Jul 2004
Posts: 5
Topics: 2

PostPosted: Wed Jan 26, 2011 11:23 pm    Post subject: Thanks All Reply with quote

Thanks Kolusu and Others. Actually I tried searching the forum but could not find it bonk . Sorry for that, now I got it. Thanks again.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group