IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL IQ: What is the value of A


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mr.Niceguy

New User


Joined: 16 Jun 2005
Posts: 63

PostPosted: Tue May 23, 2006 11:22 am
Reply with quote

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
View user's profile Send private message
pradip_silu

New User


Joined: 25 May 2005
Posts: 4
Location: bhubaneswar

PostPosted: Tue May 23, 2006 6:04 pm
Reply with quote

simple, value of A will be 250.
Back to top
View user's profile Send private message
pradip_silu

New User


Joined: 25 May 2005
Posts: 4
Location: bhubaneswar

PostPosted: Tue May 23, 2006 6:06 pm
Reply with quote

sorry , it will be 200.not 250.
Back to top
View user's profile Send private message
niharika19

New User


Joined: 23 Nov 2005
Posts: 3

PostPosted: Wed May 24, 2006 11:38 am
Reply with quote

Pradeep !

how the value of a is 200. It should be 150 i think...Can u explain me?
Back to top
View user's profile Send private message
spriya

New User


Joined: 06 Oct 2005
Posts: 42

PostPosted: Wed May 24, 2006 12:08 pm
Reply with quote

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
View user's profile Send private message
twissi

Active User


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

PostPosted: Wed May 24, 2006 12:09 pm
Reply with quote

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
View user's profile Send private message
manjunathkv

New User


Joined: 23 May 2006
Posts: 9

PostPosted: Wed May 24, 2006 12:20 pm
Reply with quote

ans is 250
Back to top
View user's profile Send private message
twissi

Active User


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

PostPosted: Wed May 24, 2006 12:57 pm
Reply with quote

Guys,

The operation was MOVE not ADD.
MOVE just rewrites everything!

Twissi.
Back to top
View user's profile Send private message
twissi

Active User


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

PostPosted: Wed May 24, 2006 12:58 pm
Reply with quote

sorry...over writes everything
Back to top
View user's profile Send private message
janamott

New User


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

PostPosted: Wed Jul 12, 2006 3:17 am
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jul 15, 2006 7:38 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top