MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Questions on PL/1

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
basheerbaba
Beginner


Joined: 03 Jan 2007
Posts: 13
Topics: 6
Location: Hyderabad,India

PostPosted: Thu Jan 26, 2012 1:04 am    Post subject: Questions on PL/1 Reply with quote

Hi,
I have two questions and answers in PL/1, but I am not understanding how those answers correct, can any body please explain me the question and answer .

1. Given the following declaration, how many bytes will be occupied by the structure?
Code:

DCL 1 A ALIGNED,
2 B FIXED BIN (31),
2 C CHAR (1),
2 D FIXED BIN (31),
2 E FIXED DEC (5,2),
2 F POINTER;
A. 16
B. 19
C. 20
D. 24
Answer: C

2.What is the output of the following program?
Code:

DCL A AREA(8000);
DCL 1 STR1 BASED(P),
2 STR1_LGTH BIN FIXED(31),
2 STR_CHAR CHAR(ALLOC_LGTH REFER(STR1_LGTH));
DCL ALLOC_LGTH BIN FIXED(31);
DCL I FIXED BIN(31);
DCL P PTR;
ALLOC_LGTH = 100;
DO I = 1 TO 10;
ALLOC STR1 IN(A);
END;
PUT SKIP LIST(CSTG(A));
A. 1016
B. 1040
C. 1056
D. 8000
Answer: C

Thanks & Regards,
Basheer
Back to top
View user's profile Send private message Yahoo Messenger
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Mon Jan 30, 2012 2:24 am    Post subject: Reply with quote

Why didn't you execute the 2 programs ?
Anweser are correct.
Back to top
View user's profile Send private message
basheerbaba
Beginner


Joined: 03 Jan 2007
Posts: 13
Topics: 6
Location: Hyderabad,India

PostPosted: Tue Jan 31, 2012 7:47 am    Post subject: Reply with quote

Hi Bauer,
I know the answers are correct, but I wanted the explanation how those answers were correct.

Thanks,
Basheer
Back to top
View user's profile Send private message Yahoo Messenger
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Tue Jan 31, 2012 8:37 am    Post subject: Reply with quote

Question (1):

Pls. see the padding bytes because of the aligned attribute !


Code:


                 Aggregate Length Table
Statement   Dims     Offset   Total Size    Base Size  Identifier
        2                 0           20           20 A
                          0                         4  B
                          4                         1  C
                          5                         3  /* padding */
                          8                         4  D
                         12                         3  E
                         15                         1  /* padding */
                         16                         4  F



Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Tue Jan 31, 2012 8:45 am    Post subject: Reply with quote

Question (b)

100 Byte per String + 4 Byte Length = 104 Byte
10 times the String a 104 Byte = 1040
16 Byte Overhead because of using AREA
so 1056 Bytes

See:

Area variables A locate mode output statement specifying an area variable transmits a field whose length is the declared size of the area, plus a 16-byte prefix containing control information. A move mode statement specifying an element area variable or a structure whose last element is an area variable transmits only the current extent of the area plus a 16-byte prefix.

from page 274, Enterprise PL/I for z/OS: Enterprise PL/I Language Reference, SC27-1460-05

Pretty nice interview question I think......


regards,
bauer
Back to top
View user's profile Send private message
basheerbaba
Beginner


Joined: 03 Jan 2007
Posts: 13
Topics: 6
Location: Hyderabad,India

PostPosted: Tue Jan 31, 2012 10:17 am    Post subject: Reply with quote

Hi Bauer,

Thank you very much for your reply, it helped me a lot.

I have some more like these, I will come up with that.

Thanks,
Basheer
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group