Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

COBOL IQ: What is the value of A

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: COBOL IQ: What is the value of A
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    Post subject:
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    Post subject:
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    Post subject: Re: COBOL IQ
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    Post subject: Re: COBOL IQ
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Re: COBOL IQ: What is the value of A
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us