View previous topic :: View next topic
|
Author |
Message |
Mr.Niceguy
New User
Joined: 16 Jun 2005 Posts: 63
|
|
|
|
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!! |
|
Back to top |
|
|
pradip_silu
New User
Joined: 25 May 2005 Posts: 4 Location: bhubaneswar
|
|
|
|
simple, value of A will be 250. |
|
Back to top |
|
|
pradip_silu
New User
Joined: 25 May 2005 Posts: 4 Location: bhubaneswar
|
|
|
|
sorry , it will be 200.not 250. |
|
Back to top |
|
|
niharika19
New User
Joined: 23 Nov 2005 Posts: 3
|
|
|
|
Pradeep !
how the value of a is 200. It should be 150 i think...Can u explain me? |
|
Back to top |
|
|
spriya
New User
Joined: 06 Oct 2005 Posts: 42
|
|
|
|
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 |
|
Back to top |
|
|
twissi
Active User
Joined: 01 Aug 2005 Posts: 105 Location: Somerset, NJ
|
|
|
|
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. |
|
Back to top |
|
|
manjunathkv
New User
Joined: 23 May 2006 Posts: 9
|
|
|
|
ans is 250 |
|
Back to top |
|
|
twissi
Active User
Joined: 01 Aug 2005 Posts: 105 Location: Somerset, NJ
|
|
|
|
Guys,
The operation was MOVE not ADD.
MOVE just rewrites everything!
Twissi. |
|
Back to top |
|
|
twissi
Active User
Joined: 01 Aug 2005 Posts: 105 Location: Somerset, NJ
|
|
|
|
sorry...over writes everything |
|
Back to top |
|
|
janamott
New User
Joined: 22 Dec 2005 Posts: 4 Location: Edison, NJ
|
|
|
|
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 |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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. |
|
Back to top |
|
|
|