Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
COBOL Interview Program Enquiry

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
sivakanuri

New User


Joined: 07 Jun 2004
Posts: 5
Location: hyderabad

PostPosted: Mon Jun 14, 2004 11:32 pm    Post subject: COBOL Interview Program Enquiry
Reply with quote

icon_smile.gif Study the following
01 A PIC 99V0 VALUE 5
01 B PIC 9V9 VALUE 6
01 C PIC 99V9 VALUE 2.5
01 D PIC 99 VALUE 3
COMPUTE A ROUNDED B C = A+B*C/D
ON SIZE ERROR PERFORM PRINT-ERROR
the comments of A.B.C after execution of the above statement are
a.A=10 B=0 C=10 b.A=10 B=9.9 C=9.9 c.A=10 B=0 C=9.9 d.A=10 B=6 C=10

plz study the code an give the valid option , and also explain hou u got the answer,urgent plz.
thanks in advance
Back to top
View user's profile Send private message

mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1203
Location: India

PostPosted: Fri Jun 18, 2004 8:07 am    Post subject: Re
Reply with quote

The answer is d) A = 10, B = 6, C = 10

You can not initialize a non-numeric (99v0) item with 5, so I assume as:

Quote:
01 A PIC 99V9 VALUE 5
01 B PIC 9V9 VALUE 6
01 C PIC 99V9 VALUE 2.5
01 D PIC 99 VALUE 3


Now the size of A is 3 Bytes (V doesn't occupy any memory)

B - 2 Bytes

C - 3 Bytes

Quote:
COMPUTE A ROUNDED B C = A+B*C/D



As by the rule,

B * C = 15.0 (It's not 15)

(B * C ) / D = 5.0

A + (( B * C) / D) = 10.0


So now the answer is

A = 10.0

B = 0.0 (has only 2 Bytes, so value truncated)

C = 10.0

But yu have specified ON SIZE ERROR...

Quote:

ON SIZE ERROR PERFORM PRINT-ERROR


If on size error specified, then insted of truncation, the value will be restored.


That's instead of 0.0 the value of B getting restored as 6.0 (as per in VALUE clause)


So your answer is now,

A = 100 (10.0 - assumed decimal)

B = 60 (6.0)

C = 100 ( 10.0)
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 Error executing Java program in OSGI ... danik56 CICS 0 Thu Apr 26, 2018 12:16 am
No new posts How to display offset thru cobol prog... tvinodkumar7 CICS 2 Sun Apr 22, 2018 8:42 pm
No new posts Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts How do you attach a DB2 plan to a CIC... John Poulakos DB2 0 Wed Apr 18, 2018 1:49 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us