View previous topic :: View next topic |
Author |
Message |
basky_g Beginner
Joined: 04 Jul 2004 Posts: 5 Topics: 2
|
Posted: Thu Jan 20, 2011 11:16 pm Post subject: Cobol puzzle |
|
|
I encountered below puzzle, can anyone help solving it
(ignore the syntax )
[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 |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Jan 21, 2011 12:34 am Post subject: |
|
|
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 |
|
 |
misi01 Advanced
Joined: 02 Dec 2002 Posts: 629 Topics: 176 Location: Stockholm, Sweden
|
Posted: Fri Jan 21, 2011 5:37 am Post subject: That depends |
|
|
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 |
|
 |
Anuj Dhawan Intermediate
Joined: 19 Jul 2007 Posts: 298 Topics: 7 Location: Mumbai,India
|
Posted: Fri Jan 21, 2011 5:45 am Post subject: |
|
|
I'm in agreement with misi01. _________________ Regards,
Anuj |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Jan 21, 2011 7:50 am Post subject: |
|
|
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 |
|
 |
RonB Beginner
Joined: 02 Dec 2002 Posts: 93 Topics: 0 Location: Orlando, FL
|
Posted: Fri Jan 21, 2011 8:29 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
basky_g Beginner
Joined: 04 Jul 2004 Posts: 5 Topics: 2
|
Posted: Wed Jan 26, 2011 11:23 pm Post subject: Thanks All |
|
|
Thanks Kolusu and Others. Actually I tried searching the forum but could not find it . Sorry for that, now I got it. Thanks again. |
|
Back to top |
|
 |
|
|