View previous topic :: View next topic |
Author |
Message |
basheerbaba Beginner

Joined: 03 Jan 2007 Posts: 13 Topics: 6 Location: Hyderabad,India
|
Posted: Thu Jan 26, 2012 1:04 am Post subject: Questions on PL/1 |
|
|
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 |
|
 |
bauer Intermediate
Joined: 10 Oct 2003 Posts: 317 Topics: 50 Location: Germany
|
Posted: Mon Jan 30, 2012 2:24 am Post subject: |
|
|
Why didn't you execute the 2 programs ?
Anweser are correct. |
|
Back to top |
|
 |
basheerbaba Beginner

Joined: 03 Jan 2007 Posts: 13 Topics: 6 Location: Hyderabad,India
|
Posted: Tue Jan 31, 2012 7:47 am Post subject: |
|
|
Hi Bauer,
I know the answers are correct, but I wanted the explanation how those answers were correct.
Thanks,
Basheer |
|
Back to top |
|
 |
bauer Intermediate
Joined: 10 Oct 2003 Posts: 317 Topics: 50 Location: Germany
|
Posted: Tue Jan 31, 2012 8:37 am Post subject: |
|
|
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 |
|
 |
bauer Intermediate
Joined: 10 Oct 2003 Posts: 317 Topics: 50 Location: Germany
|
Posted: Tue Jan 31, 2012 8:45 am Post subject: |
|
|
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 |
|
 |
basheerbaba Beginner

Joined: 03 Jan 2007 Posts: 13 Topics: 6 Location: Hyderabad,India
|
Posted: Tue Jan 31, 2012 10:17 am Post subject: |
|
|
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 |
|
 |
|
|