Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Mr.Niceguy

New User

Joined: 16 Jun 2005
Posts: 63

 Posted: Tue May 23, 2006 11:22 am    Post subject: COBOL IQ: What is the value of A Hi All, PERFORM PARA-A THRU PARA-C PARA-A. MOVE 100 TO A. IF A=100 PERFORM PARA-B. ELSE PERFORM PARA-C. END-IF. PARA-B. MOVE 150 TO A. PARA-C. MOVE 200 TO A. WHAT IS THE VALUE OF A? Bye!!

pradip_silu

New User

Joined: 25 May 2005
Posts: 4
Location: bhubaneswar

 Posted: Tue May 23, 2006 6:04 pm    Post subject: simple, value of A will be 250.
pradip_silu

New User

Joined: 25 May 2005
Posts: 4
Location: bhubaneswar

 Posted: Tue May 23, 2006 6:06 pm    Post subject: sorry , it will be 200.not 250.
niharika19

New User

Joined: 23 Nov 2005
Posts: 3

 Posted: Wed May 24, 2006 11:38 am    Post subject: Re: COBOL IQ Pradeep ! how the value of a is 200. It should be 150 i think...Can u explain me?
spriya

New User

Joined: 06 Oct 2005
Posts: 42

 Posted: Wed May 24, 2006 12:08 pm    Post subject: Re: COBOL IQ hi pradeep how the value of a b 200 in first step they r moving 100 2 a next they r checking cond it satisfies and then it moves 150 is move 2 a nw the total value is 250 correct me if i m wrong
twissi

Active User

Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

 Posted: Wed May 24, 2006 12:09 pm    Post subject: Hi All, If you notice the statements closely, all of them are MOVE statements and hence the only possible values are 100, 150 or 200. I'm just wondering where did 250 come up from?! As you can see, the last PARA executed will be PARA-C and the only statement in it is MOVE 200 TO A. Now, A will contain 200; the only exceptions are it's defined with a different data type or is not large enough to contain 200. Hope this makes sense! Cheers, Twissi.
manjunathkv

New User

Joined: 23 May 2006
Posts: 9

 Posted: Wed May 24, 2006 12:20 pm    Post subject: ans is 250
twissi

Active User

Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

 Posted: Wed May 24, 2006 12:57 pm    Post subject: Guys, The operation was MOVE not ADD. MOVE just rewrites everything! Twissi.
twissi

Active User

Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

 Posted: Wed May 24, 2006 12:58 pm    Post subject: sorry...over writes everything
janamott

New User

Joined: 22 Dec 2005
Posts: 4
Location: Edison, NJ

 Posted: Wed Jul 12, 2006 3:17 am    Post subject: Twissi is right. It's 200. 0001 MAIN. 0002 Perform PARA-A THRU PARA-C. 0003 0004 PARA-A. 0005 Move 100 to A. 0006 0007 If A = 100 0008 Perform PARA-B 0009 Else 0010 Perform PARA-C 0011 End-If. 0012 0013 PARA-B. 0014 Move 150 to A. 0015 0016 PARA-C. 0017 Move 200 to A. Line |PARA-?|Value-of-A ------|--------|------------- 0002|MAIN---|Working-Storage Value 0005|PARA-A|100 0008|PARA-A|100 0014|PARA-B|150 0011|PARA-A|150 0014|PARA-B|150 0017|PARA-C|200
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

 Posted: Sat Jul 15, 2006 7:38 am    Post subject: Re: COBOL IQ: What is the value of A The logic flow should look something like this: para-a executes para-b executes para-b executes para-c executes para-a executes para-b executes para-b executes para-c executes The paras execute once as a result of the perform and once again as a result of the fall-thru after the perform. The value of A is still 200. A better test is to change the moves to adds and see what that does to the logic flow.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to convert 2 bytes into single by... pkmurali DB2 4 Fri May 25, 2018 1:41 pm SYSADATA - COBOL - Structure displace... ganasrinivasan COBOL Programming 3 Thu May 24, 2018 9:45 pm Cobol program till a given time or fo... ankita agarwal COBOL Programming 7 Fri May 18, 2018 2:24 pm Compute statement with Cobol Z/os 5.2 Chetan Kumar COBOL Programming 2 Fri May 11, 2018 8:02 pm Ways to share data between Cobol and ... Benchwarmer Java & MQSeries 3 Thu May 10, 2018 9:16 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us